Hello, I’m making a meme generator (FCC Challenge) and I managed to easily create the App, but React is giving me this warning: ‘React Hook useEffect has a missing dependency’.
The quick solution according to React is to include values in the array ([values]), but if I do this, the App goes “crazy”. It bugs.
Code:
React is complaining because it expects you to pass values as dependency since it is declared within the body of the component and being used inside useEffect. And doing so will trigger an infinite loop I believe because you are passing it as a dependency and setting its value within useEffect. I don’t think you are even using setValues correctly.
If you want to use the current value of state for setting state, you can use the callback method instead: