Comments (3)
Thanks for such an extensive answer!
from react-frontload.
So with the current v1.x design, it's not possible.
The frontload function cannot pass new props to the underlying component. It should only return a Promise that resolves when all your data is loaded - the contents of that promise are just thrown away, the only piece of information that react-frontload
cares about is when it resolves.
So, why? Well, this was a deliberate design choice so that react-frontload
can be completely focused on data loading, and does not have to care about props / component update management - a non-trivial problem that is already solved well by libraries like react-redux
etc.
But, yes, to your point the downside of this is that you do need a state manager, even if it's a simple one you write yourself.
I have given a bit of thought to including this functionality so that react-frontload
can be used on its own without the need for a state manager, which would make a lot of sense in a lot of usecases. But I didn't want to add it before seeing a clear need for it. If it would be useful, and people want this, perhaps it is time to think about adding it.
In particular I've been thinking about this in the context of a new React hooks API for react-frontload
- wouldn't it be amazing if you could have something like a useFrontload
hook that would just pull in data as part of the render()
function, working across client and server and with all the current benefits of react-frontload
- I think this in combination with built-in state management would be really clean and powerful.
from react-frontload.
In the end, I solved it by using react's own Context API, which is pretty simple and straightforward. But I ended not using react-frontload because I already had some logic covering that part in place, i was trying to replace it but ended keeping as was.
THanks again for the answer.
from react-frontload.
Related Issues (20)
- [Question] Get a context value in frontload function? HOT 1
- useContext HOT 5
- [Feature request] specifying which props should fire reload HOT 3
- Frontload function not being called on the server HOT 5
- can't set props HOT 1
- Server Side Issues with Dispatch Action Method HOT 10
- Any way to run multiple actions from one component ? HOT 2
- Deprecated componentWillMount HOT 3
- Missing `await` in docs code example HOT 2
- ReRender on Client HOT 5
- Error code HOT 7
- Ability to disable SSR via prop HOT 1
- Replace `componentWillMount`
- Ability to reload data client-side
- Is frontload compatible with renderToNodeStream? HOT 4
- frontloadMeta.pending when nothing is returned HOT 2
- frontloadMeta.serverRendered false on webkit HOT 1
- handling error during server render HOT 1
- react-frontload with (@loadable/component ) or (suspense and lazy), hydration error HOT 1
- Frontload on server
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-frontload.