Skip to content
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

Call setState on React components once per dispatch #195

Closed
wants to merge 1 commit into from

Conversation

metcalf
Copy link

@metcalf metcalf commented Nov 17, 2015

The current ReactMixin implementation calls reactor.observe separately for each entry in the response to a React component's getDataBindings. If multiple pieces of bound data change in a single dispatch, Nuclear will call setState on the component for each of them and React will dutifully render each time. This means that the exact behavior of your component is dependent on the order in which you define your data bindings (aside from being bad for performance).

This patch switches to a single reactor.observe call that includes all of the data bindings for the component.

Fixes #193

The current ReactMixin implementation calls `reactor.observe`
separately for each entry in the response to a React component's
getDataBindings. If multiple pieces of bound data change in a single
dispatch, Nuclear will call setState on the component for each of them
and React will dutifully render each time. This means that the exact
behavior of your component is dependent on the order in which you
define your data bindings (aside from being bad for performance).

This patch switches to a single `reactor.observe` call that includes
all of the data bindings for the component.

Fixes optimizely#193
@metcalf
Copy link
Author

metcalf commented Nov 17, 2015

cc @jordangarcia

@metcalf
Copy link
Author

metcalf commented Jul 22, 2016

I'm going to close this since it hasn't gotten any attention. I'd love to see this re-opened and landed to fix #193!

@metcalf metcalf closed this Jul 22, 2016
iansinnott added a commit to iansinnott/nuclear-js-react-addons that referenced this pull request Aug 4, 2016
…onents

Relates to optimizely/nuclear-js#195. For the connect
method, this change adds only one observer to the reactor per call as opposed
to adding a separate listener for each key returned by mapStateToProps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants