Skip to content

Commit

Permalink
Fix issue facebook#21065 getInspectorDataForViewTag is not a function (
Browse files Browse the repository at this point in the history
…facebook#21237)

Summary:
Fix renderer.getInspectorDataForViewTag is not a function when try Toggle Inspector

Fixes facebook#21065

Release Notes:
--------------
[BUGFIX] [MINOR] [/react-native/Libraries/Inspector/Inspector.js]
Pull Request resolved: facebook#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 d8ffe8e commit 4690c6e
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 4690c6e

Please sign in to comment.