-
Notifications
You must be signed in to change notification settings - Fork 114
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
FluxMixin: sync with stores when props change #31
Conversation
@quazzie Do you want to try this out and see if it's working for you? |
Sure, but how do i build flummox ? :) |
Hmm, they build system is make. I'm pretty sure you can install that on Windows, with cygwin or something? If/when you have make installed, run Or just run |
@quazzie After some more testing I'm going to go ahead and merge this. Let me know if you continue to have any problems, of course. |
FluxMixin: sync with stores when props change
Why |
@msimulcik Huh, I believe there's a reason I did that but now I can't remember haha. Seems very silly now that I'm looking at it again. |
@msimulcik Nope, it's that way for a reason. Tried switching it and the test case I wrote failed. I still can't remember why, though... something about how the lifecycle methods work. |
AFAIK you really should be using |
But yeah, for let Component = React.createClass({
mixins: [FluxMixin({
test: function(props, store) {
return {
foo: 'foo is ' + props.foo,
};
},
})], Making it first parameter would be a breaking change, but the benefit is that people don't use |
Ah yes, I remember now. This will change in the next major version. I don't see this as a huge problem right now though because
Think I'll cut a new version with this change around the time 0.13 is released, along with the re-tooled array form of @gaearon I am curious why you suggest |
Maybe you're right. My instinct is doing so because otherwise it's too easy to use |
@gaearon If we pass props as a parameter to the state getter, I think we could also get away with not binding the getter to the store. Then Or... as an upgrade path we could bind a mock context so that I've come around to the view that binding is usually not a good idea. If you're using |
I'm totally pro not-binding. |
Uses
componentDidUpdate()
lifecycle method and a shallow object comparison of current props with previous props to check if props have changed. If so, gets current state from stores.This does not check for state changes, because that would result in an infinite update loop. Need to update docs to warn about using
this.state
inside a store getter.Fixes #29