K

use-force-update

Force component to render without state change
Import

Usage

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

mantine-ky3fggfl5
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
Feedback
Your feedback is most valuable contribution to the project, please share how you use Mantine, what features are missing and what is done good
Leave feedback