gs-react-state
v1.0.0
Published
react set state namespaced
Downloads
1
Readme
gs-react-state
react set state namespaced
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