react-component-updater
v1.0.7
Published
Forcibly re-render a component from anywhere through React hooks.
Downloads
5
Maintainers
Readme
React Component Updater
This package provides the ability to forcibly re-render a component from anywhere through React hooks.
- No extra files or React components required
- No dependencies but React itself
- Very small bundle size (< 1 kB)
Usage
Create the updater
import createUpdater from 'react-component-updater';
const [useMyComponentUpdater, updateMyComponent] = createUpdater();
Use the updater
const MyComponent = () => {
useMyComponentUpdater();
// ...
};
With the above code, whenever updateMyComponent
is called, MyComponent
will be re-rendered.
Update the component
The update function can be called inside or outside a React component.
updateMyComponent();