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

[Fiber] Don't call componentDidUpdate if shouldComponentUpdate returns false #8028

Merged
merged 1 commit into from
Oct 25, 2016

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Oct 21, 2016

Builds on #8015

This fix relies on the props and state objects being different to know if we can avoid a componentDidUpdate. This is not a great solution because we actually want to use the new props/state object even if sCU returns false. That's the current semantics and it can actually be important because new parent rerenders that are able to reuse props objects are more likely to have the new props object so we won't be able to quickly bail out next time. For example:

class Foo extends React.Component {
  state = { tick: 0 };
  componentDidMount() {
    setInterval(() => this.setState({ tick: this.state.tick + 1 }));
  }
  render() {
     return this.props.children;
  }
}

I don't have a better idea atm though.

@sebmarkbage sebmarkbage changed the title Don't call componentDidUpdate if shouldComponentUpdate returns false [Fiber] Don't call componentDidUpdate if shouldComponentUpdate returns false Oct 25, 2016
expect(ops).toEqual([
'componentWillReceiveProps',
'shouldComponentUpdate',
// no componenWillUpdate
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

This fix relies on the props and state objects being different
to know if we can avoid a componentDidUpdate. This is not a great
solution because we actually want to use the new props/state
object even if sCU returns false. That's the current semantics
and it can actually be important because new rerenders that are
able to reuse props objects are more likely to have the new props
object so we won't be able to quickly bail out next time.
I don't have a better idea atm though.
@sebmarkbage sebmarkbage merged commit 51e1937 into facebook:master Oct 25, 2016
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.

3 participants