simple-redux-ts
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

Redux React Simple

Simple Configuration Redux

N|Solid

Setup Redux

yarn add simple-redux-ts

Then

  • Add file to root/src project
  • src/state.json Example :
{
    "value": 6
}

Example:

Add script to head index.ts/js

...
...
import { creteStore, Provider } from 'simple-redux-ts';
...
ReactDOM.render(
    <Provider store={creteStore()}>
        <App />
    </Provider>
, document.getElementById('root'));

Other Component

Use this.props.updateState({ ... }) Access value with this.props.value

import React, { Component } from 'react';
import { connects } from 'simple-redux-ts';
...
...
class App extends Component {
    ...
    ...
    render() {
        return (
            ...
            ...
            <button onClick={() => {
                this.props.updateState({
                    value: this.props.value - 1
                });
            }}>Min</button>
            
            <div>{this.props.value}</div>
            
            <button onClick={() => {
                this.props.updateState({
                    value: this.props.value + 1
                });
            }}>Plus</button>
            ...
            ...
        );
    }
    ...
    ...
}
export default connects(App);

Features

  • One Function for update all props
  • Use props.updateState({ ... })

Dependencies (3)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i simple-redux-ts

    Weekly Downloads

    1

    Version

    1.0.9

    License

    ISC

    Unpacked Size

    5.34 kB

    Total Files

    6

    Last publish

    Collaborators

    • ukungzulfah