4 ms·
React Frontload, a library to load data into components that works with the same code on client and server render. Why? I wasn't happy with the pattern of hook
by davnicwil 5y ago
React Frontload, a library to load data into components that works with the same code on client and server render.
Why? I wasn't happy with the pattern of hooking data loading into a router, and having to load all data needed for a page upfront at the route level and then plumb it through. I just wanted a way to let components specify what data to load themselves, and then do it on the fly as they render, whether on the client or on the server.
It still surprises me a bit that React itself never built in an async lifecycle method for server render that would solve this problem. React Frontload basically acts as a polyfill for that feature - it's been slowly ticking up towards 500 stars over the past couple of years, so I can't be the only one who finds this useful :-)
https://davnicwil.com/react-frontload https://davnicwil.com/react-frontload