Answer the question
In order to leave comments, you need to log in
Where to fetch data that is used in multiple REDUX components?
I have the same data fetched on all pages.
Where can I fetch them so that I don't have to do it every time in every component?
The problem is that using the Router, we connect the components in this way.
<Layout>
<Switch>
<Route path='/' exact component={EnrolleList}/>
<Route path='/create-enrolle' exact component={CreateEnrolle}/>
<Route path='/schedule' exact component={Schedule}/>
<Route path='/exams' exact component={Exams}/>
<Route path='/results' exact component={Results}/>
<Route path='/enrollee/:id' exact component={Enrollee}/>
<Route path='/faculty-list' exact component={FacultyList}/>
<Route path='/faculties/' exact component={Faculties}/>
<Route path='/faculty/:id' exact component={Facuclty}/>
<Route path='/edit-faculty' exact component={EditFaculty}/>
<Route path='/add-new-faculty' exact component={AddNewFaculty}/>
<Redirect to='/' />
</Switch>
</Layout>
Answer the question
In order to leave comments, you need to log in
And to register in a component logic? If the data is already there, do not fetch, you can still register the date of the expair in the store, they say if the fetch was 10 minutes ago, perefetch.
The same code, it is not necessary to write in each component.
When you start the application => app.js and write data to redux already there, you will get one request to the server (Unless of course you want to update them. If you need to update, create a call in redux that will inject into useEffect like buddy, update data.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question