-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Connect refactor to use transactional setState() #373
Conversation
this.setState({ | ||
|
||
// TODO before setTimeout was not required. can I modify this test safely? it seems not a bid deal | ||
setTimeout(() => this.setState({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only modified test @gaearon but I think it's ok to modify
@@ -47,7 +37,6 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps, | |||
|
|||
const finalMergeProps = mergeProps || defaultMergeProps | |||
const { pure = true, withRef = false } = options | |||
const checkMergedEquals = pure && finalMergeProps !== defaultMergeProps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tgriesser can you take a look at that plz? I've been able to make the tests pass without using this variable. Is there a missing test-case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the premise was that if we use defaultMergeProps
, we know that it’s not going to be shallowly equal if either stateProps
or dispatchProps
changed. Therefore not even worth doing a shallowEqual
check.
…o subscription is done server-side
@@ -208,13 +173,23 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps, | |||
} | |||
} | |||
|
|||
componentWillMount() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaearon I've been able to remove the store subscription here, but I still need to be able to trigger the computation from here, otherwise nothing can be put into state for the first render and we are back to doing the computation in render()
is that ok?
@gaearon did you have time to check my PR? I've tried to run benchmarks of @mweststrate . Not sure to have done them correctly, but I actually see increased performances :) It's not huge, and maybe I did something wrong during the benchmark.
Maybe you can run them yourself and confirm? I've published the benchmark app before and after so that anyone can take a look |
Hey, great work. I’m super busy this couple of weeks so I’ll leave this hanging for now. If all tests are passing and you’re confident about it, we can cut a beta. |
thanks :) I'm going on holiday 2 weeks until the 21 so you will have some time to check the code :) I'm confident globally but not really about the |
Remove ES7 from examples
Superseded by #416 |
This is a pull request for #368
Not to be merged yet, as the code is not clean but it's enough to get some feedback, as all the existing tests are passing