-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add inserter state to the Redux store? #570
Comments
Is this state useful outside the inserter instance itself? If not, I don't see any value in moving it to the Redux Store. |
Probably not. In my experience, React works best when it doesn't worry about managing its own state. (To clarify, more when we as developers do not worry about managing React's state manually) When all state interactions are delegated out to Redux, React basically becomes a super fast rendering engine for the DOM; you can accomplish this incrementally as well. Redux can be useful for describing the state of everything and from that store the view can be built out. When working with GUIs, using Redux to basically become the Presenter for the ViewModel can be very powerful and makes testing extremely easy and fast. We don't have to use Redux in this manner, but I would encourage at least giving it a try and seeing if everyone likes it or not. The value, to me, is less cluttered components, higher modularity, and better performance as every render has no extra logic which reduces the complexity of each render. When views become essentially stateless you are exponentially increasing the performance of a render, but React is already very fast so the gains can be trivial. The performance can also go negative with this approach if not done right, like not taking advantage of the component lifecycle methods, and many more gotchas. |
I've seen this pattern "Redux everywhere" used by a lot of persons in the JS community. There are other persons advocating for more local state as well. IMO it's a matter of balance, if you need a state to be shared by multiple components, go for redux but if not just stick with local state (Redux comes with its drawbacks: Boilerplate and less modularity.
I've seen this argument a lot but it's not really true. Assuming we separate the "container component" from the "presentation component", this, in a way makes the "presentation component" reusable but let's think about it more. What's more reusable?
Allow me to doubt this, remember that any dispatch rerenders all the connected components (at least the containers's selectors) which has a tendency to grow over time while a |
Yeah definitely, most of my benchmarks for when I switched to this style on my apps were probably against terrible implementations at the start, so my perception is most likely skewed. Maybe I will run some experiments on this repo and find out if it would improve anything performance wise. But most likely the performance gains could also be done purely in the component too.
I agree a lot. Maybe I like over engineered stuff lol 😄.
Sounds good, I will try and stick to this mantra in my contributions. |
Should we close this issue out as it goes against the idea below?
|
We might need to have the state be accessible to other components for knowing if an inserter is currently open. So maybe that is the only state we would potentially want to add to the Redux Store. |
Yeah! Let's close this. I'm also thinking, we might need it when we'll tackle the inline inserter maybe. Let's keep our UI needs drive the way we handle this 👍 |
Should we add the state of the inserter to the Redux store? I think it would make it a lot easier to work with.
Since we have multiple inserters, a top and bottom etc., we would also want to probably reflect that in the store. If we add inserters mid block they can have a UID generated and then destroyed.
Potential state could look something like:
The text was updated successfully, but these errors were encountered: