[fix] usePlatformMethods guard against null hostNode

Fix #1679
This commit is contained in:
Nicolas Gallagher
2020-07-20 12:22:17 -07:00
parent 72638d028b
commit 10de987785
+8 -6
View File
@@ -53,12 +53,14 @@ export default function usePlatformMethods(hostRef: ElementRef<any>, props: Obje
hostRef, hostRef,
() => { () => {
const hostNode = hostRef.current; const hostNode = hostRef.current;
hostNode.measure = callback => UIManager.measure(hostNode, callback); if (hostNode != null) {
hostNode.measureLayout = (relativeToNode, success, failure) => hostNode.measure = callback => UIManager.measure(hostNode, callback);
UIManager.measureLayout(hostNode, relativeToNode, failure, success); hostNode.measureLayout = (relativeToNode, success, failure) =>
hostNode.measureInWindow = callback => UIManager.measureInWindow(hostNode, callback); UIManager.measureLayout(hostNode, relativeToNode, failure, success);
hostNode.setNativeProps = nativeProps => hostNode.measureInWindow = callback => UIManager.measureInWindow(hostNode, callback);
setNativeProps(hostNode, nativeProps, classList, pointerEvents, style, previousStyleRef); hostNode.setNativeProps = nativeProps =>
setNativeProps(hostNode, nativeProps, classList, pointerEvents, style, previousStyleRef);
}
return hostNode; return hostNode;
}, },
[hostRef, classList, pointerEvents, style] [hostRef, classList, pointerEvents, style]