Skip to content

Fix problems with empty component ID registration #2503

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Nov 15, 2014

Conversation

sophiebits
Copy link
Collaborator

Fixes #2493, also closes #2353 as it incorporates a variant of that fix.

  • Instead of having getEmptyComponent return <noscript /> directly, wrap it in a class that we can easily identify later as being an empty component
  • Cache the empty component element instead of recreating one each time
  • Avoid touching the nullComponentIdsRegistry dictionary at all when not dealing with empty components
  • Move empty-component tests to a separate file

Test Plan: jest

*/
function getEmptyComponent() {
var ReactEmptyComponentType = function() {};
ReactEmptyComponentType.prototype.render = function() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(My first bare class! Am I doing it right?)

Copy link
Member

Choose a reason for hiding this comment

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

If you uses classes it actually transforms to the same thing :)

class ReactEmptyComponentType {
  render() {
    ...
  }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hah, I meant my first bare React component class. I can use class if that's preferred.

@sebmarkbage
Copy link
Collaborator

We successfully managed to treat "string" and "number" as ReactNodes (where we previously only allowed ReactElements). Perhaps we can do the same for "null"?

Fixes facebook#2493, also closes facebook#2353 as it incorporates a variant of that fix.

- Instead of having getEmptyComponent return `<noscript />` directly, wrap it in a class that we can easily identify later as being an empty component
- Cache the empty component element instead of recreating one each time
- Avoid touching the nullComponentIdsRegistry dictionary at all when not dealing with empty components
- Move empty-component tests to a separate file

Test Plan: jest
@sophiebits
Copy link
Collaborator Author

Probably. Going to land this as is then work on doing that separately.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

returning null causes this.getDOMNode() to be null in componentWillUnmount
3 participants