From 0aba06a511e7281b0b5ece8cb2d4451ea9ada5c3 Mon Sep 17 00:00:00 2001 From: Chika Date: Sat, 14 May 2022 15:16:30 +0300 Subject: [PATCH] stores(hydrating): fix no calculation object --- stores/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/stores/index.js b/stores/index.js index 870e480..7a4be12 100644 --- a/stores/index.js +++ b/stores/index.js @@ -12,13 +12,12 @@ export function initializeStore(initialData) { const _store = store ?? new RootStore(); if (initialData) { - const { user = null, calculation = {} } = initialData; - const { values = {}, statuses = {}, options = {} } = calculation; + const { user = null, calculation } = initialData; _store.$user.hydrate(user); - _store.$calculation.$values.hydrate(values); - _store.$calculation.$status.hydrate(statuses); - _store.$calculation.$options.hydrate(options); + if (calculation?.values) _store.$calculation.$values.hydrate(calculation.values); + if (calculation?.statuses) _store.$calculation.$status.hydrate(calculation.statuses); + if (calculation?.options) _store.$calculation.$options.hydrate(calculation.options); } if (typeof window === 'undefined') return _store;