Skip to content

Commit 7bac53e

Browse files
feat(overmind-react): support fast refresh
1 parent 240ff0c commit 7bac53e

File tree

1 file changed

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

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export const createHook = <Config extends IConfiguration>(): (() => {
7373
}
7474
const useForceRerender = () => {
7575
const [flushId, setState] = react.useState(() => -1)
76-
const mountedRef = react.useRef(true)
76+
// We use memo here, instead of ref, to support fast-refresh
77+
const mountedRef = react.useMemo(() => ({ current: true}), [])
7778

7879
react.useEffect(
7980
() => () => {
@@ -109,8 +110,9 @@ export const createHook = <Config extends IConfiguration>(): (() => {
109110
reaction: overmind.reaction,
110111
}
111112
}
112-
const [tree] = react.useState<any>(() =>
113-
(overmind as any).proxyStateTree.getTrackStateTree()
113+
114+
const tree = react.useMemo<any>(() =>
115+
(overmind as any).proxyStateTree.getTrackStateTree(), []
114116
)
115117

116118
if (IS_PRODUCTION) {

0 commit comments

Comments
 (0)