fix initial state

pull/3094/head
Grandschtroumpf 6 years ago
parent d4b0b58432
commit 07302d036d
  1. 4
      src/lib/store.js

@ -85,7 +85,7 @@ export class EntityStore extends Store {
static fromLocal (name, keyId, initialState = {}) {
const fromLocal = localStorage.getItem(name)
const intial = fromLocal ? JSON.parse(fromLocal) : initialState
return new EntityStore(name, keyId, intial || { ids: [], actives: [] })
return new EntityStore(name, keyId, intial)
}
/**
@ -94,7 +94,7 @@ export class EntityStore extends Store {
* @param {(string|number)} keyId The name of the key used as a unique ID for the entity
* @param {EntityState} initialState The initial state used if state is not available in `localStorage`
*/
constructor (name, keyId, initialState) {
constructor (name, keyId, initialState = { ids: [], actives: [], entities: {} }) {
super(name, initialState)
this.keyId = keyId || 'id'
}

Loading…
Cancel
Save