Skip to content

Commit

Permalink
Fix issue #21065 getInspectorDataForViewTag is not a function (#21237)
Browse files Browse the repository at this point in the history
Summary:
Fix renderer.getInspectorDataForViewTag is not a function when try Toggle Inspector

Fixes #21065

Release Notes:
--------------
[BUGFIX] [MINOR] [/react-native/Libraries/Inspector/Inspector.js]
Pull Request resolved: #21237

Differential Revision: D13838339

Pulled By: cpojer

fbshipit-source-id: 363a4beba211e7868395578c7941cbda119bc753
  • Loading branch information
TranLuongTuanAnh authored and facebook-github-bot committed Jan 28, 2019
1 parent 90850ca commit 46f3285
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Libraries/Inspector/Inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,20 @@ function findRenderers(): $ReadOnlyArray<ReactRenderer> {
function getInspectorDataForViewTag(touchedViewTag: number) {
for (let i = 0; i < renderers.length; i++) {
const renderer = renderers[i];
const inspectorData = renderer.getInspectorDataForViewTag(touchedViewTag);
if (inspectorData.hierarchy.length > 0) {
return inspectorData;
if (
Object.prototype.hasOwnProperty.call(
renderer,
'getInspectorDataForViewTag',
)
) {
const inspectorData = renderer.getInspectorDataForViewTag(touchedViewTag);
if (inspectorData.hierarchy.length > 0) {
return inspectorData;
}
}
}
throw new Error('Expected to find at least one React renderer.');
}

class Inspector extends React.Component<
{
inspectedViewTag: ?number,
Expand Down

0 comments on commit 46f3285

Please sign in to comment.