diff --git a/src/store.ts b/src/store.ts index 4e6d9a83..93bb966d 100644 --- a/src/store.ts +++ b/src/store.ts @@ -132,7 +132,7 @@ export function useStore(selector, options: SelectorOptions = {}): any { __destroy.call(component, parent); }; - if (typeof result !== "object") { + if (typeof result !== "object" || result === null) { return result; } return new Proxy(result, { diff --git a/tests/store_hooks.test.ts b/tests/store_hooks.test.ts index cfa19548..9b117d77 100644 --- a/tests/store_hooks.test.ts +++ b/tests/store_hooks.test.ts @@ -49,10 +49,13 @@ describe("connecting a component to store", () => { }); test("useStore can observe primitive types and call onUpdate", async () => { - const state = { isBoolean: false }; + const state = { isBoolean: false, nullValue: null }; const actions = { setTrue({ state }) { state.isBoolean = true; + }, + setNotNull({ state }) { + state.nullValue = "ok"; } }; const store = new Store({ state, actions }); @@ -61,8 +64,10 @@ describe("connecting a component to store", () => { static template = xml`