React/Router - Fetch Data in App when Reloading page

Hi friends,
In my current project, I have a react app with different page sections organized with React Router.

Project: In app.js I fetch data from a source and provide them to other parts of the app - e.g. team.js - as a property (language={this.state.language} and use the property there. This is fine.

Problem: When I refresh a page except for home (app.js) itself, data’s not there anymore, it’s undefined. My assumption was that when fetching in app.js data will be loaded and distributed once the user opens the app because app.js is the “entry point” for the app.

Question: How is it doable that the fetches will be executed and data distributed to the different sections when refreshing the app/page?

Thanks in advance for your help.

If i understand that clear, you want to load the data even if the home didn’t reload you can achieve this by using context.
You can put the fetch function in context and after the app initialize you can get the data from any component.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.