mainam-react-utils
v1.0.5
Published
![npm version](https://badge.fury.io/js/mainam-react-utils.svg)
Downloads
4
Readme
MaiNam react utils
Install
npm i mainam-react-utils
How to use
in root component import this library
import stateUtils from 'mainam-react-utils';
stateUtils.init(React);
and then, in function component you can init state with below example:
import {createState} from 'react'
const refState = createState({
count2: 0,
count: 0
})
#support callback
refState.setState({
count: refState.state.count+1
}, newState=>{ console.log(newState) });
#support promise
let newState = await refState.setState({
count: refState.state.count+1
});
console.log(newState)