mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-01-12 22:51:09 +08:00
[fix] prevent findNodeHandle throwing on unmounted components
Fix #1097
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user