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

Fix context warning with non-pure getChildContext #3711

Closed
wants to merge 1 commit into from

Conversation

sophiebits
Copy link
Collaborator

(Requesting merge to 0.13-stable.)

Fixes #3709.

@zpao
Copy link
Member

zpao commented Apr 21, 2015

lgtm, will let @JSFB do a review as well.

Let's not merge this until we're ready to ship a 0.13.3 (would like to keep the branch build ready, which is why I did 4053465)

@zpao zpao added this to the 0.13.3 milestone Apr 21, 2015
@jimfb
Copy link
Contributor

jimfb commented Apr 21, 2015

It's a little hard for me to tell exactly why/if this is working/fixed, but it looks like there is a change in functionality here... Is ReactContext.current is getting merged when it wasn't before? Have we thought through the ramifications of that? Specifically, with regards to when the child warnings fire (or don't fire) based on the presence/value of a context variable? Is that the only functionality change?

I'm not entirely convinced this is correct. Might be worth running through it in person?

@sophiebits
Copy link
Collaborator Author

No, the merge happened before too; here I split _processChildContext into _getValidatedChildContext and _mergeChildContext.

@jimfb
Copy link
Contributor

jimfb commented Apr 21, 2015

It looks like before the context was just from the element: https://github.com/facebook/react/pull/3711/files#diff-2ee62d642502ef4bdc3a6b3d18cd4f99R807 Where/how was it being merged before?

Can you briefly describe why this works (ie. what did actually change in this diff)?

@jimfb
Copy link
Contributor

jimfb commented Apr 21, 2015

Oh, no, you're right, there is a process context there. What is the diff changing?

@sophiebits
Copy link
Collaborator Author

_processChildContext previously called getChildContext, then merged the result on top of its argument (which was either owner-based this._currentElement._context or parent-based context). mountComponent called _processChildContext directly as well as indirectly via _renderValidatedComponent, causing getChildContext to be called twice. Here, I call it once and use it when determining owner-based and parent-based context to pass down. Same for updates in _updateRenderedComponent.

@jimfb
Copy link
Contributor

jimfb commented Apr 21, 2015

Ah, got it. You're right, child context doesn't need to be called twice because it's part of the current component. Duh; I was thinking about the wrong invocations of getChildContext. Ok, lgtm.

@zpao
Copy link
Member

zpao commented May 8, 2015

Pulled in here: 80ea01d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants