4 ms·
What makes you feel that react-router encourages this?
by efdee 3y ago
What makes you feel that react-router encourages this?
- deleted 3y ago[deleted]
- Izkata 3y agoAsynchronous data loading is the core of the problem. React without any other addons like redux, where state is dumped into the page and just passed down through props would avoid the issue (though it can have a different one where the page is blank for a moment before the javascript renders the page). Same with HTML and no frontend framework, it's all loaded synchronously with page load so there's no "empty data" state. Redux encourages loading data like that, and the easy way to use Router makes it easy to do that - all URLs get sent to the same backend view to render the app, then the frontend takes the URL args and triggers ajax to get the data. During that interim when the ajax is running is when you get this empty-data state.
- efdee 3y agoThe overhead is only the latency of the ajax call on the first load (since you are going to the server to fetch the app code, then going to the server again to fetch the data, instead of going to the server and fetching the app code + the data). For every consequent page transition the performance is actually slightly higher than a full page load since (a) you're probably only fetching JSON instead the entire resulting rendered HTML and (b) you don't have to load the app code any more.