You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3.`use<Name>Store().get.value(option)` and `use<Name>Store().set.value(option)`'s `option` parameters are no longer supported. Pass the option to `use<Name>Store()` instead.
JotaiX is a custom extension of [Jotai](https://github.com/pmndrs/jotai), a primitive and flexible state management library for React. Jotai offers a
4
6
minimalistic API to manage global, derived, or async states in React, solving common issues such as unnecessary
5
7
re-renders or complex context management. JotaiX builds upon this foundation, providing enhanced utilities and patterns
@@ -63,12 +65,55 @@ The **`options`** object can include several properties to customize the behavio
63
65
The **`createAtomStore`** function returns an object (**`AtomStoreApi`**) containing the following properties and methods for interacting with the store:
64
66
65
67
- **`use<Name>Store`**:
66
-
- A function that returns the following objects: **`get`**, **`set`**, **`use`** and **`store`**, where values are hooks for each state defined in the store.
67
-
- **`get`**: Hooks for accessing a state within a component, ensuring re-rendering when the state changes. See [useAtomValue](https://jotai.org/docs/core/use-atom#useatomvalue).
68
-
- **`set`**: Hooks for setting a state within a component. See [useSetAtom](https://jotai.org/docs/core/use-atom#usesetatom).
69
-
- **`use`**: 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).
70
-
- **`store`**: A hook to access the [JotaiStore](https://jotai.org/docs/core/store) for the current context.
- A function that returns the following objects: **`useValue`**, **`useSet`**, **`useState`**, where values are hooks for each state defined in the store, and **`get`**, **`set`**, **`subscribe`**, **`store`**, where values are direct get/set accessors to modify each state.
69
+
- **`useValue`**: Hooks for accessing a state within a component, ensuring re-rendering when the state changes. See [useAtomValue](https://jotai.org/docs/core/use-atom#useatomvalue).
70
+
```js
71
+
const store =useElementStore();
72
+
const element =store.useElementValue();
73
+
// alternative
74
+
const element =useElementStore().useValue('element');
75
+
```
76
+
-**`useSet`**: Hooksforsettingastatewithinacomponent. See [useSetAtom](https://jotai.org/docs/core/use-atom#usesetatom).
77
+
``` js
78
+
const store = useElementStore();
79
+
const element = store.useSetElement();
80
+
// alternative
81
+
const element = useElementStore().useSet('element');
82
+
```
83
+
-**`useState`**: Hooksforaccessingandsettingastatewithinacomponent, ensuringre-renderingwhenthestatechanges. See [useAtom](https://jotai.org/docs/core/use-atom).
84
+
``` js
85
+
const store = useElementStore();
86
+
const element = store.useElementState();
87
+
// alternative
88
+
const element = useElementStore().useState('element');
89
+
```
90
+
-**`get`**: Directlygetthestate. Notahooksoitcouldbeusedineventhandlersorotherhooks, andthecomponentwon't re-render if the state changes. See [createStore](https://jotai.org/docs/core/store#createstore)
Derived atoms can also be defined externally by accessing the store's atoms through the `<name>Store` API. Externally defined atoms can be accessed through the store using the special `use<Name>Store().{get,set,use}.atom` hooks.
157
+
Derivedatomscanalsobedefinedexternallybyaccessingthestore's atoms through the `<name>Store` API. Externally defined atoms can be accessed through the store using special hooks:
3.Returnof`use<Name>Store`: `store`isnolongerafunction. Now it is a direct property.
325
+
``` diff
326
+
- const store = useAppStore().store();
327
+
328
+
+constappStore=useAppStore();
329
+
+constjotaiStore=appStore.store;
330
+
```
331
+
332
+
4. Return of `use<Name>Store`: `option` is no longer a valid parameter of `useValue` and `useSet`. To control the behavior, directly pass the options to `createAtomStore` or `use<Name>Store`.
0 commit comments