Skip to main content

useUrgentUpdate()

The useUrgentUpdate() hook forces a component to re-render when it gets called from anywhere inside it.

Import

import { useUrgentUpdate } from 'react-haiku';

Usage

Number: 97
import { useUrgentUpdate } from 'react-haiku';

export const Component = () => {
const randomNo = Math.floor(Math.random() * 100);
const update = useUrgentUpdate();

return (
<>
<b>{`Number: ${randomNo}`}</b>
<button onClick={update}>Force Render</button>
</>
);
}