Skip to content

korbinancell/use-deep-update-callback

Repository files navigation

use-deep-update-callback

A callback that will immutably update an object according to a given path.

NPM JavaScript Style Guide

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.inputValues.nameImput.value} onChange={event => onChange(event.target.value)} />
    </div>
  )
}

License

MIT © korbinancell


This hook is created using create-react-hook.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published