@jswork/next-react-active-state

1.0.15 • Public • Published

next-react-active-state

Active state special for react based on next-active-state.

version license size download

installation

npm install -S @jswork/next-react-active-state

apis

api params description
build - Get state and sync event handler.

usage

import NxReactActiveState from '@jswork/next-react-active-state';
import useForceUpdate from '@jswork/use-force-update';

const forceUpdate = useForceUpdate();
const {
  current: { state, sync },
} = useRef(
  NxReactActiveState.build({}, () => {
    console.log('changed main:', state);
    forceUpdate();
  })
);


<form>
  <div className="row">
    <label htmlFor="username"> username: </label>
    <input type="text" name="username" onChange={sync('username')} />
  </div>
  <div className="row">
    <label htmlFor="email"> email: </label>
    <input type="text" name="email" onChange={sync('email')}/>
  </div>
  <div className="row">
    <label htmlFor="address"> email: </label>
    <input type="text" name="formData[address]" onChange={sync()}/>
  </div>
</form>

license

Code released under the MIT license.

Package Sidebar

Install

npm i @jswork/next-react-active-state

Weekly Downloads

1

Version

1.0.15

License

MIT

Unpacked Size

8.41 kB

Total Files

5

Last publish

Collaborators

  • afeiship