use-deep-update-callback
v1.2.0
Published
A callback that will immutably update an object accoring to a given path.
Downloads
5
Readme
use-deep-update-callback
A callback that will immutably update an object according to a given path.
Install
yarn add use-deep-update-callback
Usage
import React, { useState } from 'react'
import { useDeepUpdateCallback } from 'use-deep-update-callback'
const Example = () => {
const [state, setState] = useState({ inputValues: { nameInput: { value: '' } } });
const onChange = useDeepUpdateCallback(state, ['inputValues', 'nameInput', 'value'], setState);
return (
<div>
<input value={state} onChange={event => onChange(event.target.value)} />
</div>
)
}
License
MIT © korbinancell
This hook is created using create-react-hook.