Last active
October 25, 2019 20:43
-
-
Save sag1v/8abf84e41d18896362e9a9a6427d3bc1 to your computer and use it in GitHub Desktop.
Markdium-React state update on an unmounted component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function App() { | |
| const [showPets, setShowPets] = useState(true); | |
| const toggle = () => { | |
| setShowPets(state => !state); | |
| }; | |
| return ( | |
| <div> | |
| <button onClick={toggle}>{showPets ? "hide" : "show"}</button> | |
| {showPets && <Pets />} | |
| </div> | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment