O
O
oskar barin2020-07-03 16:05:54
React
oskar barin, 2020-07-03 16:05:54

Why duplicate api requests in react SPA?

The project uses react SPA, redux, react-router, connected-react-router.
In the middleware, fetch requests are dispatched by '@@router/LOCATION_CHANGE'.
There is data that is always used when the site is first loaded.
For some reason requests occur several times.
Does anyone have any thoughts on this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2020-07-03
@hzzzzl

just a guess
in the latest versions of create-react-app some React.StrictMode was added that makes the first render twice, that's probably because of this double render and fetch data twice, see how to remove it
https://stackoverflow.com/a /61897567

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question