Skip to content

Commit 3d36d42

Browse files
committed
refactor: rename api
1 parent e580d5c commit 3d36d42

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

.changeset/sweet-nails-punch.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'jotai-x': patch
33
---
44

5-
Add hooks `useValueOfJotaiXStore`, `useSetOfJotaiXStore`, `useStateOfJotaiXStore`, `useAtomValueOfJotaiXStore`, `useAtomValueOfJotaiXStore`, `useAtomValueOfJotaiXStore` to ease react-compiler eslint plugin complains
5+
Add hooks `useStoreValue`, `useStoreSet`, `useStoreState`, `useStoreAtomValue`, `useStoreAtomSet`, `useStoreAtomState` to ease react-compiler eslint plugin complains

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ The **`createAtomStore`** function returns an object (**`AtomStoreApi`**) contai
7171
``` js
7272
const store = useElementStore();
7373

74-
const element = useValueOfJotaiXStore('element');
74+
const element = useStoreValue('element');
7575
// alternative
7676
const element = store.useElementValue();
7777
// alternative
@@ -84,15 +84,15 @@ The **`createAtomStore`** function returns an object (**`AtomStoreApi`**) contai
8484
// Approach 1: Memoize the selector yourself
8585
const toUpperCase = useCallback((element) => element.toUpperCase(), []);
8686
// Now it will only re-render if the uppercase value changes
87-
const element = useValueOfJotaiXStore(store, 'element', toUpperCase);
87+
const element = useStoreValue(store, 'element', toUpperCase);
8888
// alternative
8989
const element = store.useElementValue(toUpperCase);
9090
// alternative
9191
const element = useElementStore().useValue('element', toUpperCase);
9292
9393
// Approach 2: Pass an dependency array to prevent re-renders
9494
const [n, setN] = useState(0); // n may change during re-renders
95-
const numNthCharacter = useValueOfJotaiXStore(store, 'element', (element) => element[n], [n]);
95+
const numNthCharacter = useStoreValue(store, 'element', (element) => element[n], [n]);
9696
// alternative
9797
const numNthCharacter = store.useElementValue((element) => element[n], [n]);
9898
// alternative
@@ -101,7 +101,7 @@ The **`createAtomStore`** function returns an object (**`AtomStoreApi`**) contai
101101
- **`useSet`**: Hooks for setting a state within a component. See [useSetAtom](https://jotai.org/docs/core/use-atom#usesetatom).
102102
``` js
103103
const store = useElementStore();
104-
const element = useSetOfJotaiXStore(store, 'element');
104+
const element = useStoreSet(store, 'element');
105105
// alternative
106106
const element = store.useSetElement();
107107
// alternative
@@ -110,7 +110,7 @@ The **`createAtomStore`** function returns an object (**`AtomStoreApi`**) contai
110110
- **`useState`**: Hooks for accessing and setting a state within a component, ensuring re-rendering when the state changes. See [useAtom](https://jotai.org/docs/core/use-atom).
111111
``` js
112112
const store = useElementStore();
113-
const element = useStateOfJotaiXStore(store, 'element');
113+
const element = useStoreState(store, 'element');
114114
// alternative
115115
const element = store.useElementState();
116116
// alternative

packages/jotai-x/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ The **`createAtomStore`** function returns an object (**`AtomStoreApi`**) contai
7171
``` js
7272
const store = useElementStore();
7373

74-
const element = useValueOfJotaiXStore('element');
74+
const element = useStoreValue('element');
7575
// alternative
7676
const element = store.useElementValue();
7777
// alternative
@@ -84,15 +84,15 @@ The **`createAtomStore`** function returns an object (**`AtomStoreApi`**) contai
8484
// Approach 1: Memoize the selector yourself
8585
const toUpperCase = useCallback((element) => element.toUpperCase(), []);
8686
// Now it will only re-render if the uppercase value changes
87-
const element = useValueOfJotaiXStore(store, 'element', toUpperCase);
87+
const element = useStoreValue(store, 'element', toUpperCase);
8888
// alternative
8989
const element = store.useElementValue(toUpperCase);
9090
// alternative
9191
const element = useElementStore().useValue('element', toUpperCase);
9292
9393
// Approach 2: Pass an dependency array to prevent re-renders
9494
const [n, setN] = useState(0); // n may change during re-renders
95-
const numNthCharacter = useValueOfJotaiXStore(store, 'element', (element) => element[n], [n]);
95+
const numNthCharacter = useStoreValue(store, 'element', (element) => element[n], [n]);
9696
// alternative
9797
const numNthCharacter = store.useElementValue((element) => element[n], [n]);
9898
// alternative
@@ -101,7 +101,7 @@ The **`createAtomStore`** function returns an object (**`AtomStoreApi`**) contai
101101
- **`useSet`**: Hooks for setting a state within a component. See [useSetAtom](https://jotai.org/docs/core/use-atom#usesetatom).
102102
``` js
103103
const store = useElementStore();
104-
const element = useSetOfJotaiXStore(store, 'element');
104+
const element = useStoreSet(store, 'element');
105105
// alternative
106106
const element = store.useSetElement();
107107
// alternative
@@ -110,7 +110,7 @@ The **`createAtomStore`** function returns an object (**`AtomStoreApi`**) contai
110110
- **`useState`**: Hooks for accessing and setting a state within a component, ensuring re-rendering when the state changes. See [useAtom](https://jotai.org/docs/core/use-atom).
111111
``` js
112112
const store = useElementStore();
113-
const element = useStateOfJotaiXStore(store, 'element');
113+
const element = useStoreState(store, 'element');
114114
// alternative
115115
const element = store.useElementState();
116116
// alternative

0 commit comments

Comments
 (0)