-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Refactor findHostInstance and findNodeHandle #12575
Conversation
d2ac7f6
to
f97ce2e
Compare
@@ -402,7 +403,19 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>( | |||
); | |||
} | |||
|
|||
function findHostInstance(fiber: Fiber): PI | null { | |||
function findHostInstance(component: Object): PI | null { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is safe because findHostInstance
is being passed to DevTools below:
react/packages/react-reconciler/src/ReactFiberReconciler.js
Lines 508 to 512 in 76b4ba0
return ReactFiberDevToolsHook.injectInternals({ | |
...devToolsConfig, | |
findHostInstanceByFiber(fiber: Fiber): I | TI | null { | |
return findHostInstance(fiber); | |
}, |
DevTools assumes it can pass a Fiber there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we should be injecting into devtools from inside the reconciler. Or at least expose something opaque to inject into devtools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't we already? This code is in the reconciler. I'm just pointing out that I think you changed the signature of the function you're passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah. I see. Also, spread in production. Sad panda. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really should get rid of that. We don't want it in the reconciler so the devtools dep should go away. If it really need it, it can traverse the tree itself, since it is already Fiber aware. (If it even needs it since it has its own shadow tree anyway.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patched it for now.
f97ce2e
to
769212f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Would be nice to test DevTools still work with this.
Yea, I tested it before and after the fix. Seems to have fixed it. |
b3c51d1
to
4ab3cc3
Compare
This is just like ReactDOM does it. This also lets us get rid of injection for findNodeHandle. Instead I move NativeMethodsMixin and ReactNativeComponent to use instantiation.
The reconciler shouldn't expose the Fiber data structure. We should pass the component instance to the reconciler, since the reconciler is the thing that is supposed to be instancemap aware.
4ab3cc3
to
cf454c5
Compare
* Move findNodeHandle into the renderers and use instantiation This is just like ReactDOM does it. This also lets us get rid of injection for findNodeHandle. Instead I move NativeMethodsMixin and ReactNativeComponent to use instantiation. * Refactor findHostInstance The reconciler shouldn't expose the Fiber data structure. We should pass the component instance to the reconciler, since the reconciler is the thing that is supposed to be instancemap aware. * Fix devtools injection
The reconciler shouldn't expose the Fiber data structure. We should pass the component instance to the reconciler, since the reconciler is the thing that is supposed to be instancemap aware.
Move findNodeHandle into the renderers and use instantiation
This is just like ReactDOM does it. This also lets us get rid of injection for findNodeHandle. Instead I move NativeMethodsMixin and ReactNativeComponent to use instantiation.