Skip to content

Instantly share code, notes, and snippets.

@JenniferFuBook
Last active January 27, 2020 04:48
Show Gist options
  • Save JenniferFuBook/47a7d73560942ff309ffa970e39f2a49 to your computer and use it in GitHub Desktop.
Save JenniferFuBook/47a7d73560942ff309ffa970e39f2a49 to your computer and use it in GitHub Desktop.
const App = () => {
...
const mounted = React.useRef(true);
React.useEffect(() => {
if (mounted.current) {
some setState commands
}
return () => {
mounted.current = false;
};
});
return (
some rendering
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment