@@ -35,6 +35,7 @@ export default function createStoreInternals({
3535 disableInternalSelectFnMemoize,
3636 initialState,
3737 injections,
38+ isRebind,
3839 model,
3940 reducerEnhancer,
4041 references,
@@ -44,7 +45,7 @@ export default function createStoreInternals({
4445 ? memoizerific ( maxSelectFnMemoize ) ( x )
4546 : x ;
4647
47- const defaultState = { } ;
48+ const defaultState = isRebind ? { } : initialState || { } ;
4849 const actionThunks = { } ;
4950 const actionCreators = { } ;
5051 const actionCreatorDict = { } ;
@@ -149,12 +150,15 @@ export default function createStoreInternals({
149150 ) ;
150151 }
151152 } else if ( isStateObject ( value ) && Object . keys ( value ) . length > 0 ) {
152- set ( path , defaultState , { } ) ;
153+ const existing = get ( parentPath , defaultState ) ;
154+ if ( ! existing || isRebind ) {
155+ set ( path , defaultState , { } ) ;
156+ }
153157 recursiveExtractDefsFromModel ( value , path ) ;
154158 } else {
155159 // State
156160 const initialParentRef = get ( parentPath , initialState ) ;
157- if ( initialParentRef && key in initialParentRef ) {
161+ if ( ! isRebind && initialParentRef && key in initialParentRef ) {
158162 set ( path , defaultState , initialParentRef [ key ] ) ;
159163 } else {
160164 set ( path , defaultState , value ) ;
0 commit comments