Skip to content

Commit

Permalink
Renamed nativeHookIndex -> index
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Feb 21, 2019
1 parent a5f9b22 commit fe5271d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 95 deletions.
8 changes: 4 additions & 4 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Expand Up @@ -232,7 +232,7 @@ const Dispatcher: DispatcherType = {
// Inspect

type HooksNode = {
nativeHookIndex: number,
index: number,
name: string,
value: mixed,
subHooks: Array<HooksNode>,
Expand Down Expand Up @@ -374,7 +374,7 @@ function buildTree(rootStack, readHookLog): HooksTree {
let rootChildren = [];
let prevStack = null;
let levelChildren = rootChildren;
let nativeHookIndex = 0;
let index = 0;
let stackOfChildren = [];
for (let i = 0; i < readHookLog.length; i++) {
let hook = readHookLog[i];
Expand Down Expand Up @@ -405,7 +405,7 @@ function buildTree(rootStack, readHookLog): HooksTree {
for (let j = stack.length - commonSteps - 1; j >= 1; j--) {
let children = [];
levelChildren.push({
nativeHookIndex: -1,
index: -1,
name: parseCustomHookName(stack[j - 1].functionName),
value: undefined,
subHooks: children,
Expand All @@ -416,7 +416,7 @@ function buildTree(rootStack, readHookLog): HooksTree {
prevStack = stack;
}
levelChildren.push({
nativeHookIndex: hook.primitive === 'DebugValue' ? -1 : nativeHookIndex++,
index: hook.primitive === 'DebugValue' ? -1 : index++,
name: hook.primitive,
value: hook.value,
subHooks: [],
Expand Down
Expand Up @@ -28,7 +28,7 @@ describe('ReactHooksInspection', () => {
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
{
nativeHookIndex: 0,
index: 0,
name: 'State',
value: 'hello world',
subHooks: [],
Expand All @@ -49,12 +49,12 @@ describe('ReactHooksInspection', () => {
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
{
nativeHookIndex: -1,
index: -1,
name: 'Custom',
value: __DEV__ ? 'custom hook label' : undefined,
subHooks: [
{
nativeHookIndex: 0,
index: 0,
name: 'State',
value: 'hello world',
subHooks: [],
Expand Down Expand Up @@ -83,37 +83,37 @@ describe('ReactHooksInspection', () => {
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
{
nativeHookIndex: -1,
index: -1,
name: 'Custom',
value: undefined,
subHooks: [
{
nativeHookIndex: 0,
index: 0,
name: 'State',
subHooks: [],
value: 'hello',
},
{
nativeHookIndex: 1,
index: 1,
name: 'Effect',
subHooks: [],
value: effect,
},
],
},
{
nativeHookIndex: -1,
index: -1,
name: 'Custom',
value: undefined,
subHooks: [
{
nativeHookIndex: 2,
index: 2,
name: 'State',
value: 'world',
subHooks: [],
},
{
nativeHookIndex: 3,
index: 3,
name: 'Effect',
value: effect,
subHooks: [],
Expand Down Expand Up @@ -152,60 +152,60 @@ describe('ReactHooksInspection', () => {
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
{
nativeHookIndex: -1,
index: -1,
name: 'Bar',
value: undefined,
subHooks: [
{
nativeHookIndex: -1,
index: -1,
name: 'Custom',
value: undefined,
subHooks: [
{
nativeHookIndex: 0,
index: 0,
name: 'Reducer',
value: 'hello',
subHooks: [],
},
{
nativeHookIndex: 1,
index: 1,
name: 'Effect',
value: effect,
subHooks: [],
},
],
},
{
nativeHookIndex: 2,
index: 2,
name: 'LayoutEffect',
value: effect,
subHooks: [],
},
],
},
{
nativeHookIndex: -1,
index: -1,
name: 'Baz',
value: undefined,
subHooks: [
{
nativeHookIndex: 3,
index: 3,
name: 'LayoutEffect',
value: effect,
subHooks: [],
},
{
nativeHookIndex: -1,
index: -1,
name: 'Custom',
subHooks: [
{
nativeHookIndex: 4,
index: 4,
name: 'Reducer',
subHooks: [],
value: 'world',
},
{
nativeHookIndex: 5,
index: 5,
name: 'Effect',
subHooks: [],
value: effect,
Expand All @@ -227,7 +227,7 @@ describe('ReactHooksInspection', () => {
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
{
nativeHookIndex: 0,
index: 0,
name: 'Context',
value: 'default',
subHooks: [],
Expand Down Expand Up @@ -290,12 +290,10 @@ describe('ReactHooksInspection', () => {
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
{
nativeHookIndex: -1,
index: -1,
name: 'Custom',
value: __DEV__ ? 'bar:123' : undefined,
subHooks: [
{nativeHookIndex: 0, name: 'State', subHooks: [], value: 0},
],
subHooks: [{index: 0, name: 'State', subHooks: [], value: 0}],
},
]);
});
Expand Down

0 comments on commit fe5271d

Please sign in to comment.