mainam-react-utils

1.0.5 • Public • Published

MaiNam react utils

npm version

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)

Readme

Keywords

none

Package Sidebar

Install

npm i mainam-react-utils

Weekly Downloads

2

Version

1.0.5

License

ISC

Unpacked Size

2.31 kB

Total Files

3

Last publish

Collaborators

  • mainam