@t8/react-store 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -1
- package/package.json +1 -1
- package/src/useStore.ts +2 -1
package/dist/index.js
CHANGED
|
@@ -121,7 +121,8 @@ var PersistentStore = class extends Store {
|
|
|
121
121
|
// src/useStore.ts
|
|
122
122
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
123
123
|
function useStore(store, shouldUpdate = true) {
|
|
124
|
-
if (!isStore(store))
|
|
124
|
+
if (!isStore(store))
|
|
125
|
+
throw new Error("'store' is not an instance of Store");
|
|
125
126
|
let [, setRevision] = useState(-1);
|
|
126
127
|
let state = store.getState();
|
|
127
128
|
let setState = useMemo(() => store.setState.bind(store), [store]);
|
package/package.json
CHANGED
package/src/useStore.ts
CHANGED
|
@@ -36,7 +36,8 @@ export function useStore<T>(
|
|
|
36
36
|
store: Store<T>,
|
|
37
37
|
shouldUpdate: ShouldUpdate<T> = true,
|
|
38
38
|
): [T, SetStoreState<T>] {
|
|
39
|
-
if (!isStore(store))
|
|
39
|
+
if (!isStore<T>(store))
|
|
40
|
+
throw new Error("'store' is not an instance of Store");
|
|
40
41
|
|
|
41
42
|
let [, setRevision] = useState(-1);
|
|
42
43
|
|