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

Check props.data in the componentDidUpdate() lifecycle #39

Closed
ma2ciek opened this issue Sep 20, 2018 · 3 comments
Closed

Check props.data in the componentDidUpdate() lifecycle #39

ma2ciek opened this issue Sep 20, 2018 · 3 comments
Assignees
Labels
Milestone

Comments

@ma2ciek
Copy link
Contributor

ma2ciek commented Sep 20, 2018

Follow-up of the #37 and #37 (comment)

componentDidUpdate() {
if ( this.editor && this.editor.getData() !== this.props.data ) {
this.editor.setData( this.props.data );
}
}

As @pomek proposed, we should check if the this.props.data is equal to undefined to prevent an infinite update loop.

@ma2ciek
Copy link
Contributor Author

ma2ciek commented Sep 20, 2018

Not sure if this should be marked as a bug or as an enhancement 😄

@pomek
Copy link
Member

pomek commented Sep 20, 2018

Mhm, I proposed aborting the update editor's data if this.props.data does not exist:

// Aborts updating the editor's data if "data" property wasn't specified.
if ( !( 'data' in this.props ) ) { 
  return; 
}

@pomek
Copy link
Member

pomek commented Sep 20, 2018

And of course, it's a bug that occurs in very specified environments.

@pomek pomek self-assigned this Nov 21, 2018
@pomek pomek added this to the iteration 21 milestone Nov 21, 2018
ma2ciek added a commit that referenced this issue Nov 26, 2018
Fix: Prevented an infinite loop when the `data` property is missing. Closes #39.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants