use-event-callback
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

React hook useEventCallback

Aimed to be easier to use than useCallback and solve problems raised in this ticket.

useEventCallback doesn't need any dependencies list. The returned function should not be used during rendering.

Example

import useEventCallback from 'use-event-callback';
 
const Input = () => {
  const [value, setValue] = useState('');
  const onChange = useEventCallback((event) => {
    setValue(event.target.value);  
  });
 
  return <input value={value} onChange={onChange} />;
}

Package Sidebar

Install

npm i use-event-callback

Weekly Downloads

32,980

Version

0.1.0

License

ISC

Unpacked Size

3.98 kB

Total Files

8

Last publish

Collaborators

  • volune