-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
React 16 shallow renderer batched updates discussion #10355
Comments
Thank you for creating this issue!
This motivation was to support the following case. class App extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 1
};
}
onClick() {
this.setState({count: this.state.count + 1});
// :
this.setState({count: this.state.count + 1});
}
render() {
return <button onClick={() => this.onClick()}>click</button>;
}
} I guess supporting batched updates is not hard work. koba04@ca78c92 I wonder if we should support consistent behaviors between shallow renderer and other fiber renderers. I think keeping consistent behaviors between the renderers will become harder after released Fiber. But enzyme also does that works like batched updates and supporting all lifecycle methods and many developers use shallow renderer through |
This is off topic, but I'd like to add all lifecycle methods support in a future release even though it is a breaking change. |
Thanks for the feedback! 😁
I'm a little confused by the mention of the
It doesn't make sense for shallow renderer to support things like refs or
Shallow renderer only renders one level deep.
I think this is prohibitively difficult (to make the fiber reconciler behave as "shallow"). I tried it initially before just writing shallow renderer as a stand-alone implementation.
I think this may cause more harm than good. Calling |
I do wish for some consistency though. It’s odd we call |
I don't think we should call componentDidUpdate. |
We still have time to break this. 😄 |
I sent a PR for this: #10372 |
@bvaughn
It makes sense. We are already having test renderer, I can use it if I need ref and all lifecycle methods. When shallow renderer was released, it's an only way to test components without DOM. |
This is my misunderstanding. You are right. |
This issue can be closed. |
React 16 comes with a new, completely rewritten shallow renderer. The new renderer doesn't currently provide an
unstable_batchedUpdates
method. This issue is for discussion about whether it should implement that method.cc @flarnie and @lelandrichardson who recently discussed wrt its potential impact on Enzyme.
cc @koba04 who initially added the integration with Enzyme and who also provided an example implementation.
The text was updated successfully, but these errors were encountered: