Skip to content

Commit

Permalink
Fix: Error while converting null to RootStore (#2479 by @midrizi)
Browse files Browse the repository at this point in the history
[skip ci]

* Fix: Error while converting `null` to `RootStore`

Fixes the following issue:

[mobx-state-tree] Error while converting `null` to `RootStore`: value `null` is not assignable to type: `RootStore` (Value is not a plain object).

* Remove null type from restoredState3
  • Loading branch information
midrizi authored Aug 4, 2023
1 parent a50d1f3 commit e79aea1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion boilerplate/app/models/helpers/setupRootStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function setupRootStore(rootStore: RootStore) {

try {
// load the last known state from AsyncStorage
restoredState = (await storage.load(ROOT_STATE_STORAGE_KEY)) as RootStoreSnapshot | null
restoredState = ((await storage.load(ROOT_STATE_STORAGE_KEY)) ?? {}) as RootStoreSnapshot
applySnapshot(rootStore, restoredState)
} catch (e) {
// if there's any problems loading, then inform the dev what happened
Expand Down

0 comments on commit e79aea1

Please sign in to comment.