-
Notifications
You must be signed in to change notification settings - Fork 47.7k
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
consistent owner for stateless component #6534
Conversation
What side effect? How is the code change related to the new unit test? (they look orthogonal at first glance) |
you can run the tc. if
|
if (__DEV__) { |
stateless component's element will have owner when update:
ReactCurrentOwner.current = this; |
so will trigger ref change:
nextElement._owner !== prevElement._owner || |
b1a354b
to
ff083b9
Compare
@yiminghe updated the pull request. |
ff083b9
to
e437116
Compare
@yiminghe updated the pull request. |
ping @jimfb . better to keep the same behaviour in dev and production environment(except warning message). |
Hmm. I don’t think #6362 is related per se. - if (__DEV__) {
- ReactCurrentOwner.current = this;
- try {
- inst = new Component(publicProps, publicContext, ReactUpdateQueue);
- } finally {
- ReactCurrentOwner.current = null;
- }
- } else {
- inst = new Component(publicProps, publicContext, ReactUpdateQueue);
- } |
@gaearon can you run the above tc on current master |
e437116
to
b237c44
Compare
@yiminghe updated the pull request. |
I guess this fix is correct. The logic here is very confusing though and I don't know what we can do to avoid bugs in the future. ReactRef should also not check the owner for function refs because there is no reason to, so I amended your commit to check that too and merged as b11540c. |
I missed this since it was closed and pushed separately. I'll get it into the next release. |
(cherry picked from commit b11540c)
How i can validate a group of checkboxes? |
component should not have owner for both create and update lifecycle when in production.(not consistent will cause ref function call)
react/src/renderers/shared/reconciler/ReactRef.js
Line 65 in dc6fc8c