use-force-update

Force component to render without state change
Import

Usage

Hook returns a function, when this function is called component rerenders:

mantine-p83dftnqm
import { Button, Text, Group } from '@mantine/core';
import { useForceUpdate, randomId } from '@mantine/hooks';
function Demo() {
const forceUpdate = useForceUpdate();
return (
<Group position="center">
<Text>{randomId()}</Text>
<Button onClick={forceUpdate}>Force update</Button>
</Group>
);
}

Definition

function useForceUpdate(): () => void;
Build fully functional accessible web applications with ease