Created
October 25, 2019 20:23
-
-
Save sag1v/08d4c5dc7bd5a0f74062a6fd5aa6cf22 to your computer and use it in GitHub Desktop.
Markdium-React race condition bug
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
| useEffect(() => { | |
| let abort = false; | |
| if (pets.selectedPet) { | |
| dispatch({ type: "FETCH_PET" }); | |
| getPet(pets.selectedPet).then(data => { | |
| if(!abort){ | |
| dispatch({ type: "FETCH_PET_SUCCESS", payload: data }); | |
| } | |
| }); | |
| } else { | |
| dispatch({ type: "RESET" }); | |
| } | |
| return () => abort = true; | |
| }, [pets.selectedPet]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment