Answer the question
In order to leave comments, you need to log in
React why is there an infinite request?
I need to transfer the Data (sections for the menu) to the SearchTree component when loading.
If I pass it like this, then there is a constant update every second.
This is the App component:
...
<SearchTree sections={store.dispatch(fetchAllSections())} store={store} />
...
store.dispatch(fetchAllSections());
Answer the question
In order to leave comments, you need to log in
When mounting the SearchTree component, data is requested from the server and passed to it. Moreover, they are passed in the store parameter, and not in sections. After the data has arrived, the component containing the SearchTree is re-rendered and the data is requested again. And so endlessly.
It’s worth making a method like getData in the App component, where you can request data once when mounting.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question