File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -212,11 +212,14 @@ export function createReducer<S extends NotFunction<any>>(
212
212
? executeReducerBuilderCallback ( mapOrBuilderCallback )
213
213
: [ mapOrBuilderCallback , actionMatchers , defaultCaseReducer ]
214
214
215
- const getInitialState = ( ) =>
216
- createNextState (
217
- isStateFunction ( initialState ) ? initialState ( ) : initialState ,
218
- ( ) => { }
219
- )
215
+ // Ensure the initial state gets frozen either way
216
+ let getInitialState : ( ) => S
217
+ if ( isStateFunction ( initialState ) ) {
218
+ getInitialState = ( ) => createNextState ( initialState ( ) , ( ) => { } )
219
+ } else {
220
+ const frozenInitialState = createNextState ( initialState , ( ) => { } )
221
+ getInitialState = ( ) => frozenInitialState
222
+ }
220
223
221
224
function reducer ( state = getInitialState ( ) , action : any ) : S {
222
225
let caseReducers = [
You can’t perform that action at this time.
0 commit comments