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
|`notification`| Required |`ReactNode`| - | A Notification element. |
68
68
|`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 |
69
70
70
71
### `getStoreKey`
71
72
@@ -90,6 +91,21 @@ You can override this key by passing a custom function as the `getStoreKey` prop
90
91
/>
91
92
```
92
93
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
+
93
109
### `notification`
94
110
95
111
When `<AutoPersistInStoreBase>` component applies the changes from the store to a form, react-admin informs users with a notification.
|`notification`| Required |`ReactNode`| - | A Notification element. |
76
76
|`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 |
77
78
78
79
### `getStoreKey`
79
80
@@ -96,6 +97,21 @@ useAutoPersistInStore({
96
97
});
97
98
```
98
99
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
+
99
115
### `notification`
100
116
101
117
When `useAutoPersistInStore` hook applies the changes from the store to a form, react-admin informs users with a notification.
0 commit comments