Skip to content

Commit b689796

Browse files
fix(overmind-react): fix updating react hook
1 parent f3ae2d5 commit b689796

File tree

1 file changed

+5
-5
lines changed
  • packages/node_modules/overmind-react/src

1 file changed

+5
-5
lines changed

packages/node_modules/overmind-react/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ export const createHook = <Config extends Configuration>(
7979
typeof component.__componentId === 'undefined'
8080
? nextComponentId++
8181
: component.__componentId
82-
const [tree, updateComponent] = useState<any>(() =>
83-
(overmind as any).proxyStateTree.getTrackStateTree()
84-
)
82+
const [{ tree }, updateComponent] = useState<any>(() => ({
83+
tree: (overmind as any).proxyStateTree.getTrackStateTree(),
84+
}))
8585

8686
if (IS_PRODUCTION) {
8787
tree.track(() => {
88-
updateComponent((state) => state)
88+
updateComponent(({ tree }) => ({ tree }))
8989
})
9090

9191
useEffect(
@@ -100,7 +100,7 @@ export const createHook = <Config extends Configuration>(
100100
)
101101

102102
tree.track((_, paths, flushId) => {
103-
updateComponent((state) => state)
103+
updateComponent(({ tree }) => ({ tree }))
104104
overmind.eventHub.emitAsync(EventType.COMPONENT_UPDATE, {
105105
componentId: component.__componentId,
106106
componentInstanceId,

0 commit comments

Comments
 (0)