From 10de98778598d795b776d96d01ff01dbcf6b7f7b Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Mon, 20 Jul 2020 12:22:17 -0700 Subject: [PATCH] [fix] usePlatformMethods guard against null hostNode Fix #1679 --- .../src/hooks/usePlatformMethods.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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]