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
Copy file name to clipboardExpand all lines: README.md
+34-2Lines changed: 34 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,7 @@ The **`options`** object can include several properties to customize the behavio
59
59
- **`delay`**: If you need to introduce a delay in state updates, you can specify it here. Optional.
60
60
- **`effect`**: A React component that can be used to run effects inside the provider. Optional.
61
61
- **`extend`**: Extend the store with derived atoms based on the store state. Optional.
62
+
- **`infiniteRenderDetectionLimit`**: In non production mode, it will throw an error if the number of `useValue` hook calls exceeds this limit during the same render. Optional.
62
63
63
64
#### Return Value
64
65
@@ -73,14 +74,20 @@ The **`createAtomStore`** function returns an object (**`AtomStoreApi`**) contai
73
74
// alternative
74
75
const element =useElementStore().useValue('element');
75
76
```
76
-
-Advanced: `useValue`supportsparameters`selector`, whichisafunction that takes the current value and returns a new value and parameter `equalityFn`, which is a function that compares the previous and new values and only re-renders if they are not equal. Internally, it uses [selectAtom](https://jotai.org/docs/utilities/select#selectatom)
77
+
-Advanced: `useValue`supportsparameters`selector`, whichisafunction that takes the current value and returns a new value and parameter `equalityFn`, which is a function that compares the previous and new values and only re-renders if they are not equal. Internally, it uses [selectAtom](https://jotai.org/docs/utilities/select#selectatom). You must memoize `selector`/`equalityFn` adequately.
// Provide selector and equalityFn and all of their deps
326
+
useValue('key', selector, equalityFn, [...]);
327
+
```
328
+
329
+
Theerrorcouldalsobeafalsepositive, sincetheinternalcounterissharedacrossall`useValue`callsofthesame store. Ifyourcomponenttreeisverydeepandusesthesamestore's `useValue` multiple times, then the limit could be reached. To deal with that, `createAtomStore` supports an optional parameter `infiniteRenderDetectionLimit`. You can configure that with a higher limit.
Copy file name to clipboardExpand all lines: packages/jotai-x/README.md
+34-2Lines changed: 34 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,7 @@ The **`options`** object can include several properties to customize the behavio
59
59
- **`delay`**: If you need to introduce a delay in state updates, you can specify it here. Optional.
60
60
- **`effect`**: A React component that can be used to run effects inside the provider. Optional.
61
61
- **`extend`**: Extend the store with derived atoms based on the store state. Optional.
62
+
- **`infiniteRenderDetectionLimit`**: In non production mode, it will throw an error if the number of `useValue` hook calls exceeds this limit during the same render. Optional.
62
63
63
64
#### Return Value
64
65
@@ -73,14 +74,20 @@ The **`createAtomStore`** function returns an object (**`AtomStoreApi`**) contai
73
74
// alternative
74
75
const element =useElementStore().useValue('element');
75
76
```
76
-
-Advanced: `useValue`supportsparameters`selector`, whichisafunction that takes the current value and returns a new value and parameter `equalityFn`, which is a function that compares the previous and new values and only re-renders if they are not equal. Internally, it uses [selectAtom](https://jotai.org/docs/utilities/select#selectatom)
77
+
-Advanced: `useValue`supportsparameters`selector`, whichisafunction that takes the current value and returns a new value and parameter `equalityFn`, which is a function that compares the previous and new values and only re-renders if they are not equal. Internally, it uses [selectAtom](https://jotai.org/docs/utilities/select#selectatom). You must memoize `selector`/`equalityFn` adequately.
// Provide selector and equalityFn and all of their deps
326
+
useValue('key', selector, equalityFn, [...]);
327
+
```
328
+
329
+
Theerrorcouldalsobeafalsepositive, sincetheinternalcounterissharedacrossall`useValue`callsofthesame store. Ifyourcomponenttreeisverydeepandusesthesamestore's `useValue` multiple times, then the limit could be reached. To deal with that, `createAtomStore` supports an optional parameter `infiniteRenderDetectionLimit`. You can configure that with a higher limit.
0 commit comments