Inspecting stateless components.
Summary: Fixes #4602 Fixes a bug where the app crashes when you try to inspect a stateless component. Fixed by replacing all occurrences of the getPublicInstance method in Libraries/Inspector/Inspector.js with the _instance property instead. Defaults to an empty object if _instance is falsy. Closes https://github.com/facebook/react-native/pull/4642 Reviewed By: svcscm Differential Revision: D2734491 Pulled By: androidtrunkagent fb-gh-sync-id: 4ea753b7e0ef3fd05af2d80abadc365c5c787f98
This commit is contained in:
parent
c9d796fc6a
commit
c489660f26
|
@ -98,7 +98,9 @@ class Inspector extends React.Component {
|
|||
|
||||
setSelection(i: number) {
|
||||
var instance = this.state.hierarchy[i];
|
||||
var publicInstance = instance.getPublicInstance();
|
||||
// if we inspect a stateless component we can't use the getPublicInstance method
|
||||
// therefore we use the internal _instance property directly.
|
||||
var publicInstance = instance._instance || {};
|
||||
UIManager.measure(React.findNodeHandle(instance), (x, y, width, height, left, top) => {
|
||||
this.setState({
|
||||
inspected: {
|
||||
|
@ -115,7 +117,9 @@ class Inspector extends React.Component {
|
|||
this.state.devtoolsAgent.selectFromReactInstance(instance, true);
|
||||
}
|
||||
var hierarchy = InspectorUtils.getOwnerHierarchy(instance);
|
||||
var publicInstance = instance.getPublicInstance();
|
||||
// if we inspect a stateless component we can't use the getPublicInstance method
|
||||
// therefore we use the internal _instance property directly.
|
||||
var publicInstance = instance._instance || {};
|
||||
var props = publicInstance.props || {};
|
||||
this.setState({
|
||||
panelPos: pointerY > Dimensions.get('window').height / 2 ? 'top' : 'bottom',
|
||||
|
|
Loading…
Reference in New Issue