Closed muescha closed 4 years ago
(。・_・。)ノI’m sorry for the late reply. @muescha persistMiddleware only works after actions running and only do the write stuff, If you want to use state from Persistance storage, I think you need a extra step:
const model: ModelType<StateType, ActionParams> = {
state: {
// user: defaultUser
user: JSON.parse(localStorage.getItem('__REACT_MODEL__'))['you model name']
},
actions: {
// actions here
}
}
thx
i used the code from this example:
https://github.com/byte-fe/react-model#how-can-i-make-persist-models
the debug in console prints the saved and also changed state from localStorage. but it not get initialized with the
initalValue
- only with thedefaultUser
:/