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

RN findNodeHandle no longer adds props directly to read-only owner #10520

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/renderers/native/findNodeHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ if (__DEV__) {
}

import type {Fiber} from 'ReactFiber';
import type {ReactInstance} from 'ReactInstanceType';

/**
* ReactNative vs ReactWeb
Expand Down Expand Up @@ -60,11 +59,10 @@ import type {ReactInstance} from 'ReactInstanceType';
// accidentally deep-requiring this version.
function findNodeHandle(componentOrHandle: any): any {
if (__DEV__) {
// TODO: fix this unsafe cast to work with Fiber.
var owner = ((ReactCurrentOwner.current: any): ReactInstance | null);
if (owner !== null) {
var owner = ReactCurrentOwner.current;
if (owner !== null && owner.stateNode !== null) {
warning(
owner._warnedAboutRefsInRender,
owner.stateNode._warnedAboutRefsInRender,
'%s is accessing findNodeHandle inside its render(). ' +
'render() should be a pure function of props and state. It should ' +
'never access something that requires stale data from the previous ' +
Expand All @@ -73,7 +71,7 @@ function findNodeHandle(componentOrHandle: any): any {
getComponentName(owner) || 'A component',
);

owner._warnedAboutRefsInRender = true;
owner.stateNode._warnedAboutRefsInRender = true;
}
}
if (componentOrHandle == null) {
Expand Down