Skip to main content

useRerender

This hook returns a function that you can use to rerender the component. It is usually used to rerender mutable data.

API

function useRerender(): () => void;

Example

0
import React from "react";
import { useRerender } from "@lilib/hooks";

let count = 0;

function Example() {
const rerender = useRerender();

function handleClick() {
count++;
rerender();
}

return (
<>
<button onClick={handleClick}>+1</button> {count}
</>
);
}

export default Example;