1.0.0 • Published 4 years ago

gs-react-state v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

gs-react-state

react set state namespaced

NPM JavaScript Style Guide

Install

npm install --save gs-react-state

Usage

import React, { Component } from "react";

import gsReactState from "gs-react-state";

export default class App extends Component {
    constructor() {
        super();
        this.$state = gsReactState.bind(this);
    }

    state = {
        form: { d: 4, e: 5 }
    };

    UNSAFE_componentWillMount() {
        this.$state("form")
            .$remove("e")
            .$empty()
            .$add({ a: 1, b: 2, c: 3 })
            .$leave("a", "b")
            .$end();
    }
    render() {
        return (
            <div>
                {this.state.form.a}
                {this.state.form.b}
                {this.state.form.c}
                {this.state.form.d}
                {this.state.form.e}
            </div>
        );
    }
}

License

MIT © kyo4311