adverse-sapphire
adverse-sapphire17mo ago

#Api Triggering

I have seen that same api calls are triggering two times why this was happening.This will effects the performance right
4 Replies
stormy-gold
stormy-gold17mo ago
This is probably occurs with <React.StrictMode> This is the expected behavior because <React.StrictMode> renders that component twice. When you remove <React.StrictMode> you will see the request only triggering once. I suggest you should not remove <React.StrictMode> It only works on dev mode.
adverse-sapphire
adverse-sapphire17mo ago
Whats the solution for that
stormy-gold
stormy-gold17mo ago
you can read this https://refine.dev/blog/react-strict-mode-in-react-18/ https://reactjs.org/docs/strict-mode.html but long story short, if you remove <React.StrictMode> on index.ts it will trigger once. but i strongly recommend do not remove <React.StrictMode>. it will not trigger twice on production because strict mode not work on production. actually, this is not a bug. it's a feature to hunt bugs
adverse-sapphire
adverse-sapphire17mo ago
Thanks 🙏