Skip to content

Commit 8897016

Browse files
committed
fix(ssr): fix hot reload issue on ssr + dev mode
1 parent 7a9ee87 commit 8897016

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ type ArgumentTypes<F extends Function> = F extends (...args: infer A) => any
185185
: never
186186

187187
// v3.0
188+
// TODO: ArgumentTypes<A[P]>[0] = undefined | string
188189
type getConsumerActionsType<A extends Actions<any, any, any>> = {
189190
[P in keyof A]: ArgumentTypes<A[P]>[0] extends undefined
190191
? (params?: ArgumentTypes<A[P]>[0]) => ReturnType<A[P]>

src/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ function Model<M extends Models, MT extends ModelType, E>(
7474
Global.Actions[name] = model.actions
7575
Global.AsyncState[name] = model.asyncState
7676
} else {
77-
if (!Global.State[name]) {
77+
// If you develop on SSR mode, hot reload will still keep the old Global reference, so initialState won't change unless you restart the dev server
78+
if (!Global.State[name] || !initialState) {
7879
Global.State[name] = Global.State[model.__id]
7980
}
8081
Global.Actions[name] = Global.Actions[model.__id]

0 commit comments

Comments
 (0)