Skip to content

Commit f7dafa9

Browse files
committed
moved to cjs
1 parent c86f8e3 commit f7dafa9

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@poly-state/react",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"description": "React bindings for React",
55
"main": "dist/index.js",
66
"repository": "https://github.com/poly-state/react.git",

src/useNewStore.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ReturnStoreType, StateConstraint } from '@poly-state/poly-state';
2+
import { useEffect, useState } from 'react';
3+
4+
export const useStore = <T extends StateConstraint>(store: ReturnStoreType<T>) => {
5+
const [state, setState] = useState(store.getState());
6+
useEffect(() => store.subscribe(setState), [store]);
7+
return state;
8+
};

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"allowSyntheticDefaultImports": true,
1010
"strict": true,
1111
"forceConsistentCasingInFileNames": true,
12-
"module": "ES6",
12+
"module": "commonjs",
1313
"moduleResolution": "node",
1414
"isolatedModules": true,
1515
"jsx": "react-jsx",

0 commit comments

Comments
 (0)