Skip to content

Commit fe5271d

Browse files
author
Brian Vaughn
committed
Renamed nativeHookIndex -> index
1 parent a5f9b22 commit fe5271d

File tree

4 files changed

+75
-95
lines changed

4 files changed

+75
-95
lines changed

packages/react-debug-tools/src/ReactDebugHooks.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ const Dispatcher: DispatcherType = {
232232
// Inspect
233233

234234
type HooksNode = {
235-
nativeHookIndex: number,
235+
index: number,
236236
name: string,
237237
value: mixed,
238238
subHooks: Array<HooksNode>,
@@ -374,7 +374,7 @@ function buildTree(rootStack, readHookLog): HooksTree {
374374
let rootChildren = [];
375375
let prevStack = null;
376376
let levelChildren = rootChildren;
377-
let nativeHookIndex = 0;
377+
let index = 0;
378378
let stackOfChildren = [];
379379
for (let i = 0; i < readHookLog.length; i++) {
380380
let hook = readHookLog[i];
@@ -405,7 +405,7 @@ function buildTree(rootStack, readHookLog): HooksTree {
405405
for (let j = stack.length - commonSteps - 1; j >= 1; j--) {
406406
let children = [];
407407
levelChildren.push({
408-
nativeHookIndex: -1,
408+
index: -1,
409409
name: parseCustomHookName(stack[j - 1].functionName),
410410
value: undefined,
411411
subHooks: children,
@@ -416,7 +416,7 @@ function buildTree(rootStack, readHookLog): HooksTree {
416416
prevStack = stack;
417417
}
418418
levelChildren.push({
419-
nativeHookIndex: hook.primitive === 'DebugValue' ? -1 : nativeHookIndex++,
419+
index: hook.primitive === 'DebugValue' ? -1 : index++,
420420
name: hook.primitive,
421421
value: hook.value,
422422
subHooks: [],

packages/react-debug-tools/src/__tests__/ReactHooksInspection-test.js

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('ReactHooksInspection', () => {
2828
let tree = ReactDebugTools.inspectHooks(Foo, {});
2929
expect(tree).toEqual([
3030
{
31-
nativeHookIndex: 0,
31+
index: 0,
3232
name: 'State',
3333
value: 'hello world',
3434
subHooks: [],
@@ -49,12 +49,12 @@ describe('ReactHooksInspection', () => {
4949
let tree = ReactDebugTools.inspectHooks(Foo, {});
5050
expect(tree).toEqual([
5151
{
52-
nativeHookIndex: -1,
52+
index: -1,
5353
name: 'Custom',
5454
value: __DEV__ ? 'custom hook label' : undefined,
5555
subHooks: [
5656
{
57-
nativeHookIndex: 0,
57+
index: 0,
5858
name: 'State',
5959
value: 'hello world',
6060
subHooks: [],
@@ -83,37 +83,37 @@ describe('ReactHooksInspection', () => {
8383
let tree = ReactDebugTools.inspectHooks(Foo, {});
8484
expect(tree).toEqual([
8585
{
86-
nativeHookIndex: -1,
86+
index: -1,
8787
name: 'Custom',
8888
value: undefined,
8989
subHooks: [
9090
{
91-
nativeHookIndex: 0,
91+
index: 0,
9292
name: 'State',
9393
subHooks: [],
9494
value: 'hello',
9595
},
9696
{
97-
nativeHookIndex: 1,
97+
index: 1,
9898
name: 'Effect',
9999
subHooks: [],
100100
value: effect,
101101
},
102102
],
103103
},
104104
{
105-
nativeHookIndex: -1,
105+
index: -1,
106106
name: 'Custom',
107107
value: undefined,
108108
subHooks: [
109109
{
110-
nativeHookIndex: 2,
110+
index: 2,
111111
name: 'State',
112112
value: 'world',
113113
subHooks: [],
114114
},
115115
{
116-
nativeHookIndex: 3,
116+
index: 3,
117117
name: 'Effect',
118118
value: effect,
119119
subHooks: [],
@@ -152,60 +152,60 @@ describe('ReactHooksInspection', () => {
152152
let tree = ReactDebugTools.inspectHooks(Foo, {});
153153
expect(tree).toEqual([
154154
{
155-
nativeHookIndex: -1,
155+
index: -1,
156156
name: 'Bar',
157157
value: undefined,
158158
subHooks: [
159159
{
160-
nativeHookIndex: -1,
160+
index: -1,
161161
name: 'Custom',
162162
value: undefined,
163163
subHooks: [
164164
{
165-
nativeHookIndex: 0,
165+
index: 0,
166166
name: 'Reducer',
167167
value: 'hello',
168168
subHooks: [],
169169
},
170170
{
171-
nativeHookIndex: 1,
171+
index: 1,
172172
name: 'Effect',
173173
value: effect,
174174
subHooks: [],
175175
},
176176
],
177177
},
178178
{
179-
nativeHookIndex: 2,
179+
index: 2,
180180
name: 'LayoutEffect',
181181
value: effect,
182182
subHooks: [],
183183
},
184184
],
185185
},
186186
{
187-
nativeHookIndex: -1,
187+
index: -1,
188188
name: 'Baz',
189189
value: undefined,
190190
subHooks: [
191191
{
192-
nativeHookIndex: 3,
192+
index: 3,
193193
name: 'LayoutEffect',
194194
value: effect,
195195
subHooks: [],
196196
},
197197
{
198-
nativeHookIndex: -1,
198+
index: -1,
199199
name: 'Custom',
200200
subHooks: [
201201
{
202-
nativeHookIndex: 4,
202+
index: 4,
203203
name: 'Reducer',
204204
subHooks: [],
205205
value: 'world',
206206
},
207207
{
208-
nativeHookIndex: 5,
208+
index: 5,
209209
name: 'Effect',
210210
subHooks: [],
211211
value: effect,
@@ -227,7 +227,7 @@ describe('ReactHooksInspection', () => {
227227
let tree = ReactDebugTools.inspectHooks(Foo, {});
228228
expect(tree).toEqual([
229229
{
230-
nativeHookIndex: 0,
230+
index: 0,
231231
name: 'Context',
232232
value: 'default',
233233
subHooks: [],
@@ -290,12 +290,10 @@ describe('ReactHooksInspection', () => {
290290
let tree = ReactDebugTools.inspectHooks(Foo, {});
291291
expect(tree).toEqual([
292292
{
293-
nativeHookIndex: -1,
293+
index: -1,
294294
name: 'Custom',
295295
value: __DEV__ ? 'bar:123' : undefined,
296-
subHooks: [
297-
{nativeHookIndex: 0, name: 'State', subHooks: [], value: 0},
298-
],
296+
subHooks: [{index: 0, name: 'State', subHooks: [], value: 0}],
299297
},
300298
]);
301299
});

0 commit comments

Comments
 (0)