useForceUpdate
A custom hook that forces the component to re-render when the returned function is called.
Code
Interface
typescript
// type DispatchWithoutAction = () => void;
const useForceUpdate: () => React.DispatchWithoutAction
Usage
typescript
import { useForceUpdate } from '@modern-kit/react';
const Example = () => {
const forceUpdate = useForceUpdate();
const handleForceUpdate = useCallback(() => {
forceUpdate();
}, [forceUpdate]);
return (
<div>
<button onClick={handleForceUpdate}>Button</button>;
</div>
);
};