Skip to content

Commit 023fd24

Browse files
authored
fix: update react custom plugin count handling logic position (#173)
Fixes #167 ### Changes Update to execute count increment/decrement before history push. The pages affected by this change are as follows: - https://tanstack.com/devtools/latest/docs/framework/react/guides/custom-plugins - https://tanstack.com/devtools/latest/docs/framework/react/examples/custom-devtools
1 parent 4c0446f commit 023fd24

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

docs/framework/react/guides/custom-plugins.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ export function createCounter() {
2020
return {
2121
getCount: () => count,
2222
increment: () => {
23-
history.push(count)
2423
count++
24+
history.push(count)
2525
},
2626
decrement: () => {
27-
history.push(count)
2827
count--
28+
history.push(count)
2929
},
3030
};
3131
}
@@ -82,22 +82,22 @@ export function createCounter() {
8282
return {
8383
getCount: () => count,
8484
increment: () => {
85-
history.push(count)
8685
count++
86+
history.push(count)
8787

8888
// The emit eventSuffix must match that of the EventMap defined in eventClient.ts
8989
DevtoolsEventClient.emit('counter-state', {
90-
count: count,
91-
history: history,
90+
count,
91+
history,
9292
})
9393
},
9494
decrement: () => {
95-
history.push(count)
9695
count--
96+
history.push(count)
9797

9898
DevtoolsEventClient.emit('counter-state', {
99-
count: count,
100-
history: history,
99+
count,
100+
history,
101101
})
102102
},
103103
}

examples/react/custom-devtools/src/counter.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ export function createCounter() {
77
return {
88
getCount: () => count,
99
increment: () => {
10+
count++
1011
history.push(count)
1112

1213
// The emit eventSuffix must match that of the EventMap defined in eventClient.ts
1314
DevtoolsEventClient.emit('counter-state', {
14-
count: count++,
15-
history: history,
15+
count,
16+
history,
1617
})
1718
},
1819
decrement: () => {
20+
count--
1921
history.push(count)
2022

2123
DevtoolsEventClient.emit('counter-state', {
22-
count: count--,
23-
history: history,
24+
count,
25+
history,
2426
})
2527
},
2628
}

0 commit comments

Comments
 (0)