Random Quote Machine (Running Through Every Quote)

My quote machine is running through every quote in the API without stopping. I dont know why this is happening, I want it to render a new quote every time I reload the page. Can someone tell me why this is happening?

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36

Challenge: Build a Random Quote Machine

Link to the challenge:

Remember that by default, useEffect runs on every render.
So in your effect, you are setting a new state, which will cause a re-render which will turn the useEffect again.

You can get more info about it on the official react docs.

If you want to run it only on the first render (on mount) pass an empty array as a second argument:

useEffect( () => {...}, [])

Also for the future debugging from a screenshot is sub-par.
Always share your code and a reproducible demo to help others help you in the best possible way.

Hope this helps :slight_smile:

Thank you! this helped.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.