-
-
Save Santiago-j-s/73df71d57eeddfe4e51a3b8e196bafb6 to your computer and use it in GitHub Desktop.
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
| export function Component() { | |
| const [something, setSomething] = useState(); | |
| /* ... */ | |
| const trackSomething = useCallback(() => { | |
| track("something", { something.email }) | |
| }, [something]); | |
| useEffect(() => { | |
| if ( | |
| fetcher.data?.message === I_WANT_TO_TRACK_WHEN_THIS_HAPPENS && | |
| checkoutFetcherType === "done" | |
| ) { | |
| trackSomething(); | |
| } | |
| /* eslint-disable-next-line react-hooks/exhaustive-deps -- | |
| * We don't want to re-run this effect each time `something` changes | |
| * | |
| * This could be solved with an effect event in the future: | |
| * - https://react.dev/learn/separating-events-from-effects#declaring-an-effect-event | |
| * | |
| * Enable the rule before making any changes to this effect to ensure | |
| * that the only dep missing is `trackSomething` | |
| */ | |
| }, [checkoutFetcherType, fetcher.data?.message]); | |
| /* ... hundreds of lines with a lot of effects without correct deps T.T */ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment