-
Notifications
You must be signed in to change notification settings - Fork 248
Consider replacing redux in favor of react context #40
Comments
I'd really say it depends on what you try to achieve. statinamic already seems opinionated on some parts, and I see it more like a boilerplate than a library. if you want to provide a way to manage data across components whatever the tree structure is in this boilerplate, then I'd say keep redux. If you want it to be more of a library, keep it minimal, and just use your own provider and decorator. |
Statinamic is a collection of lib + a boilerplate generator + docs: you start with a boilerplate that use statinamic libs to help you generate a website with react and webpack. So Statinamic is opininated because of these 2 things (react and webpack). Except that nothing is mandatory (no required structures etc). There is a minimal boilerplate that is required to allow some flexibility (choose your styles flavor (inline, css modules, sass...) and I am currently writing a helper to generate the minimal required boilerplate. The idea is to allow to create a website very easily with one command
Not a lot of things, no user interaction. That's what I was thinking about using react context instead of redux. Currently there is already a context provider to share some metadata about your project (eg: package.json to get homepage url, stuff like that) and I was thinking about using it for all the shared (read only - or sort of) data. The only interaction is: you click on a link, if page data are not in the store, we fetch a json to get those. |
I use redux in almost every project so using redux is one the reasons why I use statinamic. Also with redux, I can just add reducers that listen for default action of statinamic. Some example use cases: show a loading indicator when getting new page's info. show a error message when getting new page's info failed, ... In the other hand, keeping redux would make statinamic too opinionated. One more thing, if you decide to keep redux, you might need to use immutable.js (or similars) because redux store is holding all pages info which could lead to a performance issue on large page. |
I think thoses things should be possible without redux (and more easy to implement without using redux). I will try to avoid redux and maybe will consider removing it. |
I think we should consider this again. I don't see the benefit of using redux anymore. We aren't modify anything in the state (just add more page). This should be a good alternative solution |
I think we should not need anything if we remove redux. All the logic for downloading is in PageContainer, maybe we can make a simple fetch/registry directly in here for now. And that might help for hot loading md. |
It is your call. Removing redux would help us reduce the bundle size |
Totally. That's why I opened this issue in the first place :) |
So. Shall we change status of this issue ? |
Done :) |
I think that implement this would be easy, just mutate a window object. 💃 |
An alternative http://madx.me/articles/a-simpler-alternative-to-flux-and-redux.html poke @madx |
I was investigating this tool to use with a MobX store app, so removing Redux is 👍 from me. |
Will be handled soon (hopefully) |
Any updates on this issue? It's really nice to have easy way to add your preferred state store. I'm also using mobx currently, and would like to add it to my static site app as well. It's not such simple to replace redux right now. |
I will try to work on that for the next release. Should not take that long. |
👍 thanks for the update |
Going to be fixed with #925 |
Since we don't do a lot of modifications (ie: no modification at all for now), we might consider replacing redux usage by react context (that are now documented http://facebook.github.io/react/docs/context.html).
That should be clearly enough to just "pass" some data (collection and page components references) that are declared during app initialization.
It don't really see any downside from the current usage.
Any thoughts? poke @bloodyowl
The text was updated successfully, but these errors were encountered: