-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Mutating this.props.layouts #178
Comments
+1 -- this issue (the fact that the library depends on holding/managing/mutating the current layout in its own state) makes it nearly impossible make a decent implementation using redux or similar. If anyone's done this, I would love to hear how. belive this was also discussed in #156 |
I managed to get something decent working by
still a bit hacky, and i'd love to see the library take a better approach to state in the future |
I'm with you on this - would like to do a similar approach to what I did with Then consumers will simply have to listen to |
great, yeah, i think for nontrivial cases most people are going to want to manage the state themselves -- having a HOC that provides the same "just works" behavior, + a stateless core would be a great approach. |
Cool, i think it will clean up a lot of code when you don't have to keep state yourself. Making it more stable. And also, "everyone" in the React community is used to and expects components to work this way. |
Hi, is there anyone working on this? |
The library shouldn't be mutating the input |
@STRML this is great. Is the change present in release 0.13.7 ? |
Yeah. On Oct 4, 2016 2:57 AM, "Arun Kumar Jain" notifications@github.com wrote:
|
so i have been testing this a lot now and it seems to be good :) |
Hi guys, sorry to "reopen" this issue, but 0.17.1 still mutates the state. It adds some new breakpoints when non are defined. I would also love a version, where the component is stateless and we can manage our own state. Outside drag is ideal candidate for such a behavior. Other than that, I have another faulty behavior: This is my component definition:
What I experience as problem is that droppingItem is mutating my Redux state (without me wanting so via the onLayoutChange, and even worse: it is doing it twice consecutive times: once with the new item in place ("dropping-elem") and once without it. Needless to say, I cannot see my droppingItem in the layout because of it. I would benefit greatly if the onLayoutChange is more verbose on the changes it makes. I will use it for the resize, but I would skip it for the dropping item rearrangements. If someone has been stuck here, I would greatly appreciate the help :) I don't feel like forking the library and moding it locally. Not good for sustainability :) |
I am maybe doing something wrong, but I am trying to make an editor where i provide the layouts using the "layouts" props from my internal state. I then listen for changes using onLayoutChange, and update my own state.layouts which is then propagated down to the ResponsiveGrid component. Anyway
https://github.com/STRML/react-grid-layout/blob/master/lib/ResponsiveReactGridLayout.jsx#L130-L142
It looks like this code is mutating the props.layouts object, and therefore my state object is mutated in place. Is this by design. It makes it hard to create an "controlled" component.
Does my question even make sense :)
The text was updated successfully, but these errors were encountered: