-2

I am trying to fitch words randomly from the api and im trying to console log them, but the function is being re rendered multiple times although im not using it anywhere else, i tried many things but yet it is not working. Please help

I am trying to console log it the word only once, I tried using the await async didn't work, i tried using UseRef still didn't work.[enter image description here][1]

[1]: https://i.stack.imgur.com/orp2v.png this image will show my code. any help will be appreciated

  • Welcome to Stack Overflow! Relevant code and error messages need to be included in your question *as text*, [not as pictures of text](https://meta.stackoverflow.com/q/285551/328193). Just linking to screen shots makes it more difficult for people to help you. To learn more about this community and how we can help you, please start with the [tour] and read [ask] and its linked resources. – David Apr 26 '23 at 13:15

1 Answers1

0

The double re-rendering is happenning due to React's strict mode.

In short, React re-renders functions that should be pure to catch bugs while in development.

You can read more about it in the official docs.