Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function DidUpdateDemo() {
const [value, setValue] = useState(0);
const [hasUpdated, setHasUpdated] = useState(false);
useDidUpdate(() => {
alert("Update");
setHasUpdated(true);
}, [value]);
return (
<>
<button> setValue(value + 1)}>Value is {value}</button>
<p>Has updated at least once - {hasUpdated.toString()}</p>
);
}
storiesOf("useDidUpdate", module)