mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-31 17:53:50 +00:00
[fix] prevent findNodeHandle throwing on unmounted components
Fix #1097
This commit is contained in:
@@ -8,4 +8,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { findDOMNode } from 'react-dom';
|
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;
|
return;
|
||||||
}
|
}
|
||||||
const node = findNodeHandle(this);
|
const node = findNodeHandle(this);
|
||||||
// Next state is determined by comparison to existing state (in the DOM).
|
if (node) {
|
||||||
// Existing state has already gone through i18n transform
|
// Next state is determined by comparison to existing state (in the DOM).
|
||||||
const domProps = createDOMProps(null, nativeProps, style =>
|
// Existing state has already gone through i18n transform
|
||||||
styleResolver.resolveWithNode(style, node)
|
const domProps = createDOMProps(null, nativeProps, style =>
|
||||||
);
|
styleResolver.resolveWithNode(style, node)
|
||||||
UIManager.updateView(node, domProps, this);
|
);
|
||||||
|
UIManager.updateView(node, domProps, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user