Skip to content

Commit bd7e28f

Browse files
authored
Merge pull request #11148 from marmelab/doc/ra-core-ee-a8b665af8117cfc0a7cdabe9b8f17e6a70f1a972
[Doc] Update RA Core EE documentation
2 parents 7fb9726 + cd32be9 commit bd7e28f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

docs_headless/src/content/docs/AutoPersistInStoreBase.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ It works both on create and edit forms.
6666
| --------------------- | -------- | ----------- | ------------------------------------ | ------------------------------------ |
6767
| `notification` | Required | `ReactNode` | - | A Notification element. |
6868
| `getStoreKey` | - | `function` | - | Function to use your own store key. |
69+
| `maxAge` | - | `number` | - | The age in seconds before a stored value is removed from the store |
6970

7071
### `getStoreKey`
7172

@@ -90,6 +91,21 @@ You can override this key by passing a custom function as the `getStoreKey` prop
9091
/>
9192
```
9293

94+
### `maxAge`
95+
96+
Storing many values in the `store` (especially with `localStorage`) may consume all the allowed space depending on the browser. You can provide a number of seconds to the `maxAge` prop so that older values are automatically removed whenever new values are stored.
97+
98+
**Note**: This feature requires a [Store](https://marmelab.com/ra-core/store/) that implements the `listItems` function (both `localStorageStore` and `memoryStore` do).
99+
100+
**Note**: This feature is disabled when providing the `getStoreKey` prop.
101+
102+
```tsx
103+
<AutoPersistInStoreBase
104+
maxAge={10 * 60} // 10 minutes
105+
notification={<AutoPersistNotification />}
106+
/>
107+
```
108+
93109
### `notification`
94110

95111
When `<AutoPersistInStoreBase>` component applies the changes from the store to a form, react-admin informs users with a notification.

docs_headless/src/content/docs/useAutoPersistInStore.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ It works both on create and edit forms.
7474
| --------------------- | -------- | ----------- | ------------------------------------ | ------------------------------------ |
7575
| `notification` | Required | `ReactNode` | - | A Notification element. |
7676
| `getStoreKey` | - | `function` | - | Function to use your own store key. |
77+
| `maxAge` | - | `number` | - | The age in seconds before a stored value is removed from the store |
7778

7879
### `getStoreKey`
7980

@@ -96,6 +97,21 @@ useAutoPersistInStore({
9697
});
9798
```
9899

100+
### `maxAge`
101+
102+
Storing many values in the `store` (especially with `localStorage`) may consume all the allowed space depending on the browser. You can provide a number of seconds to the `maxAge` prop so that older values are automatically removed whenever new values are stored.
103+
104+
**Note**: This feature requires a [Store](https://marmelab.com/ra-core/store/) that implements the `listItems` function (both `localStorageStore` and `memoryStore` do).
105+
106+
**Note**: This feature is disabled when providing the `getStoreKey` prop.
107+
108+
```tsx
109+
useAutoPersistInStore({
110+
maxAge: 10 * 60, // 10 minutes
111+
notification: <AutoPersistNotification />
112+
});
113+
```
114+
99115
### `notification`
100116

101117
When `useAutoPersistInStore` hook applies the changes from the store to a form, react-admin informs users with a notification.

0 commit comments

Comments
 (0)