@react-hookbox/event-callback
v1.3.0
Published
Material UI's useEventCallback with better type definitions.
Downloads
22
Maintainers
Readme
@react-hookbox/event-callback
Material UI's useEventCallback with better type definitions.
Install
npm install --save @react-hookbox/event-callback
or
yarn add @react-hookbox/event-callback
Usage
both for JavaScript and Typescript:
import { useEventCallback } from '@react-hookbox/event-callback';
// OR
// import useEventCallback from '@react-hookbox/event-callback';
// then
const myCallback = useEventCallback((num, str) => {
return str.repeat(Math.min(num, 2));
});
useEventCallback
updates the callback it's using after
an "effective-time". So make sure to use it as a callback
or in a useEffect
which is placed after useEventCallback
;
Params
fn
. This is a required function parameter. The returned value will have the same type.Note: The return value will be updated after an "effect-ive time".
That means the returned value should be used as an event callback or in an event callback.
License
MIT © hakobpogh