next-react-active-state
Active state special for react based on next-active-state.
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.