Skip to content

Only purgeID on ReactDOMComponent unmount #1568

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

Merged
merged 1 commit into from
Jan 31, 2015
Merged

Only purgeID on ReactDOMComponent unmount #1568

merged 1 commit into from
Jan 31, 2015

Conversation

syranide
Copy link
Contributor

Fixes #1567

@@ -406,6 +406,7 @@ ReactDOMComponent.Mixin = {
this.unmountChildren();
ReactEventEmitter.deleteAllListeners(this._rootNodeID);
ReactComponent.Mixin.unmountComponent.call(this);
ReactMount.purgeID(this._rootNodeID);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can you move this above the super call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, will do.

@sophiebits
Copy link
Collaborator

Looks good to me.

@syranide
Copy link
Contributor Author

Technically, the neatest solution would be for ReactTextComponent to use a React.DOM.span internally, but I'm guessing the overhead would be unpreferable.

@sophiebits
Copy link
Collaborator

Or perhaps add it to ReactBrowserComponentMixin? Not sure.

@syranide
Copy link
Contributor Author

Hmm, yeah that's a good point.

I guess the upside of using React.DOM.span in ReactTextComponent would be that only ReactDOMComponent actually generates DOM nodes then (I currently have a special-case for ReactTextComponent, since it doesn't have a tagName). We could also get rid of ReactBrowserComponentMixin then I think?

@sophiebits
Copy link
Collaborator

@syranide
Copy link
Contributor Author

Right, but the solution would be the same for it then, use React.DOM.* instead.

@syranide
Copy link
Contributor Author

Related to discussion, #1598

@@ -97,8 +88,6 @@ var ReactComponent = {
'ReactComponent: injectEnvironment() can only be called once.'
);
mountImageIntoNode = ReactComponentEnvironment.mountImageIntoNode;
unmountIDFromEnvironment =
ReactComponentEnvironment.unmountIDFromEnvironment;
Copy link
Member

Choose a reason for hiding this comment

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

This was the only place using ReactComponentEnvironment.unmountIDFromEnvironment - can we probably get rid of that now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zpao Hmm? That's exactly what's going on here? :) (I find no occurences of unmountIDFromEnvironment)

Copy link
Member

Choose a reason for hiding this comment

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

not a smart man

@syranide
Copy link
Contributor Author

Btw, rebased this too.

Test plan: grunt test and manually interacting with our application

@syranide
Copy link
Contributor Author

@sebmarkbage Rewrote to fix conflicts, it's still the same basically, but... I chose to use ReactComponentBrowserEnvironment.unmountIDFromEnvironment because that's what ReactDOMTextComponent is using, is that correct or should both be using ReactMount.purgeID directly?

EDIT: I've also ran this PR against our app and I have witnessed no stale nodes in the nodeCache, except for #2988 which is not caused by this PR.

Warning, it seems React's focus/selection restoration it repopulating the cache with the last focused nodes after being purged (when unmounted). I'm not sure if it's happening in stable as well, but it's happening when this PR is applied. Will have to look into that before this can be merged. It's happening in stable as well.

syranide added a commit that referenced this pull request Jan 31, 2015
Only purgeID on ReactDOMComponent and ReactDOMTextComponent unmount
@syranide syranide merged commit a170629 into facebook:master Jan 31, 2015
@syranide syranide deleted the dompurge branch January 31, 2015 17:21
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.

(un)mountComponent seems to behave improperly for the root component of the update
4 participants