API Getting Called Twice
Answered
Barbary Lion posted this in #help-forum
Barbary LionOP
I am calling an api in my Next component to join game and it should be called only once, but for some reason it's getting called twice. I think the reason of it that next renders the component twice. is there any way to eliminate this. I have tried using ref, empty dependency array, and some other but nothings seems to be working
Answered by English Spot
I believe it's because of react 18 strict mode
https://react.dev/blog/2022/03/29/react-v18#new-strict-mode-behaviors
https://react.dev/blog/2022/03/29/react-v18#new-strict-mode-behaviors
3 Replies
English Spot
I believe it's because of react 18 strict mode
https://react.dev/blog/2022/03/29/react-v18#new-strict-mode-behaviors
https://react.dev/blog/2022/03/29/react-v18#new-strict-mode-behaviors
Answer
English Spot
This only happens in development, and not in production
Maybe need to remove strict mode or something
Maybe need to remove strict mode or something
Barbary LionOP
I added this in my next config
reactStrictMode: false,
reactStrictMode: false,