[fix] prevent findNodeHandle throwing on unmounted components

Fix #1097
This commit is contained in:
Nicolas Gallagher
2018-09-09 11:11:18 -07:00
parent f062eded40
commit b56a737d62
2 changed files with 20 additions and 7 deletions

View File

@@ -8,4 +8,15 @@
*/
import { findDOMNode } from 'react-dom';
export default findDOMNode;
const findNodeHandle = component => {
let node;
try {
node = findDOMNode(component);
} catch (e) {}
return node;
};
export default findNodeHandle;

View File

@@ -100,12 +100,14 @@ const NativeMethodsMixin = {
return;
}
const node = findNodeHandle(this);
// Next state is determined by comparison to existing state (in the DOM).
// Existing state has already gone through i18n transform
const domProps = createDOMProps(null, nativeProps, style =>
styleResolver.resolveWithNode(style, node)
);
UIManager.updateView(node, domProps, this);
if (node) {
// Next state is determined by comparison to existing state (in the DOM).
// Existing state has already gone through i18n transform
const domProps = createDOMProps(null, nativeProps, style =>
styleResolver.resolveWithNode(style, node)
);
UIManager.updateView(node, domProps, this);
}
}
};