Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a87843d

Browse files
committed
fix: attempt json parse on store init
1 parent 2888f4c commit a87843d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/state/store.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ class Store {
3333

3434
@action
3535
initializeStores(state) {
36+
const _state = _.isString(state)
37+
? JSON.parse(state)
38+
: state;
39+
3640
Object.keys(this.$imports)
3741
.forEach((key) => {
3842
const StoreClass = this.$imports[key];
39-
const $state = state[key] || {};
43+
const $state = _state[key] || {};
4044
const $obj = new StoreClass($state);
4145
const $extend = $obj.___extend || null;
4246
Object.assign($obj, $state);

0 commit comments

Comments
 (0)