useUpdate
Run effect after the component is updated or the deps are changed, ignore on mount.
API
function useUpdate(
effect: React.EffectCallback,
deps?: React.DependencyList
): void;
Example
import React from "react";
import { useUpdate } from "@lilib/hooks";
function Example() {
const [signal, setSignal] = useState({});
useUpdate(() => {
console.log("Signal changed");
}, [signal]);
return <button onClick={() => setSignal({})}>Change signal</button>;
}