diff --git a/packages/react-native-web/src/hooks/usePlatformMethods.js b/packages/react-native-web/src/hooks/usePlatformMethods.js index f98094ef..4b21333b 100644 --- a/packages/react-native-web/src/hooks/usePlatformMethods.js +++ b/packages/react-native-web/src/hooks/usePlatformMethods.js @@ -53,12 +53,14 @@ export default function usePlatformMethods(hostRef: ElementRef, props: Obje hostRef, () => { const hostNode = hostRef.current; - hostNode.measure = callback => UIManager.measure(hostNode, callback); - hostNode.measureLayout = (relativeToNode, success, failure) => - UIManager.measureLayout(hostNode, relativeToNode, failure, success); - hostNode.measureInWindow = callback => UIManager.measureInWindow(hostNode, callback); - hostNode.setNativeProps = nativeProps => - setNativeProps(hostNode, nativeProps, classList, pointerEvents, style, previousStyleRef); + if (hostNode != null) { + hostNode.measure = callback => UIManager.measure(hostNode, callback); + hostNode.measureLayout = (relativeToNode, success, failure) => + UIManager.measureLayout(hostNode, relativeToNode, failure, success); + hostNode.measureInWindow = callback => UIManager.measureInWindow(hostNode, callback); + hostNode.setNativeProps = nativeProps => + setNativeProps(hostNode, nativeProps, classList, pointerEvents, style, previousStyleRef); + } return hostNode; }, [hostRef, classList, pointerEvents, style]