Skip to content

Commit

Permalink
Renamed inspected hook isEditable to isStateEditable
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Feb 27, 2019
1 parent dc1517a commit 1c6b5b3
Show file tree
Hide file tree
Showing 3 changed files with 193 additions and 73 deletions.
6 changes: 3 additions & 3 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ const Dispatcher: DispatcherType = {

type HooksNode = {
index: number,
isEditable: boolean,
isStateEditable: boolean,
name: string,
value: mixed,
subHooks: Array<HooksNode>,
Expand Down Expand Up @@ -407,7 +407,7 @@ function buildTree(rootStack, readHookLog): HooksTree {
let children = [];
levelChildren.push({
index: -1,
isEditable: false,
isStateEditable: false,
name: parseCustomHookName(stack[j - 1].functionName),
value: undefined,
subHooks: children,
Expand All @@ -420,7 +420,7 @@ function buildTree(rootStack, readHookLog): HooksTree {
const {primitive} = hook;
levelChildren.push({
index: primitive === 'DebugValue' ? -1 : index++,
isEditable: primitive === 'Reducer' || primitive === 'State',
isStateEditable: primitive === 'Reducer' || primitive === 'State',
name: primitive,
value: hook.value,
subHooks: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('ReactHooksInspection', () => {
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
{
isEditable: true,
isStateEditable: true,
index: 0,
name: 'State',
value: 'hello world',
Expand All @@ -50,13 +50,13 @@ describe('ReactHooksInspection', () => {
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
{
isEditable: false,
isStateEditable: false,
index: -1,
name: 'Custom',
value: __DEV__ ? 'custom hook label' : undefined,
subHooks: [
{
isEditable: true,
isStateEditable: true,
index: 0,
name: 'State',
value: 'hello world',
Expand Down Expand Up @@ -86,20 +86,20 @@ describe('ReactHooksInspection', () => {
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
{
isEditable: false,
isStateEditable: false,
index: -1,
name: 'Custom',
value: undefined,
subHooks: [
{
isEditable: true,
isStateEditable: true,
index: 0,
name: 'State',
subHooks: [],
value: 'hello',
},
{
isEditable: false,
isStateEditable: false,
index: 1,
name: 'Effect',
subHooks: [],
Expand All @@ -108,20 +108,20 @@ describe('ReactHooksInspection', () => {
],
},
{
isEditable: false,
isStateEditable: false,
index: -1,
name: 'Custom',
value: undefined,
subHooks: [
{
isEditable: true,
isStateEditable: true,
index: 2,
name: 'State',
value: 'world',
subHooks: [],
},
{
isEditable: false,
isStateEditable: false,
index: 3,
name: 'Effect',
value: effect,
Expand Down Expand Up @@ -161,26 +161,26 @@ describe('ReactHooksInspection', () => {
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
{
isEditable: false,
isStateEditable: false,
index: -1,
name: 'Bar',
value: undefined,
subHooks: [
{
isEditable: false,
isStateEditable: false,
index: -1,
name: 'Custom',
value: undefined,
subHooks: [
{
isEditable: true,
isStateEditable: true,
index: 0,
name: 'Reducer',
value: 'hello',
subHooks: [],
},
{
isEditable: false,
isStateEditable: false,
index: 1,
name: 'Effect',
value: effect,
Expand All @@ -189,7 +189,7 @@ describe('ReactHooksInspection', () => {
],
},
{
isEditable: false,
isStateEditable: false,
index: 2,
name: 'LayoutEffect',
value: effect,
Expand All @@ -198,32 +198,32 @@ describe('ReactHooksInspection', () => {
],
},
{
isEditable: false,
isStateEditable: false,
index: -1,
name: 'Baz',
value: undefined,
subHooks: [
{
isEditable: false,
isStateEditable: false,
index: 3,
name: 'LayoutEffect',
value: effect,
subHooks: [],
},
{
isEditable: false,
isStateEditable: false,
index: -1,
name: 'Custom',
subHooks: [
{
isEditable: true,
isStateEditable: true,
index: 4,
name: 'Reducer',
subHooks: [],
value: 'world',
},
{
isEditable: false,
isStateEditable: false,
index: 5,
name: 'Effect',
subHooks: [],
Expand All @@ -246,7 +246,7 @@ describe('ReactHooksInspection', () => {
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
{
isEditable: false,
isStateEditable: false,
index: 0,
name: 'Context',
value: 'default',
Expand Down Expand Up @@ -310,12 +310,18 @@ describe('ReactHooksInspection', () => {
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
{
isEditable: false,
isStateEditable: false,
index: -1,
name: 'Custom',
value: __DEV__ ? 'bar:123' : undefined,
subHooks: [
{isEditable: true, index: 0, name: 'State', subHooks: [], value: 0},
{
isStateEditable: true,
index: 0,
name: 'State',
subHooks: [],
value: 0,
},
],
},
]);
Expand Down
Loading

0 comments on commit 1c6b5b3

Please sign in to comment.