diff --git a/docs_headless/src/content/docs/AutoPersistInStoreBase.md b/docs_headless/src/content/docs/AutoPersistInStoreBase.md index 65e31192090..0c138b5be0f 100644 --- a/docs_headless/src/content/docs/AutoPersistInStoreBase.md +++ b/docs_headless/src/content/docs/AutoPersistInStoreBase.md @@ -66,6 +66,7 @@ It works both on create and edit forms. | --------------------- | -------- | ----------- | ------------------------------------ | ------------------------------------ | | `notification` | Required | `ReactNode` | - | A Notification element. | | `getStoreKey` | - | `function` | - | Function to use your own store key. | +| `maxAge` | - | `number` | - | The age in seconds before a stored value is removed from the store | ### `getStoreKey` @@ -90,6 +91,21 @@ You can override this key by passing a custom function as the `getStoreKey` prop /> ``` +### `maxAge` + +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. + +**Note**: This feature requires a [Store](https://marmelab.com/ra-core/store/) that implements the `listItems` function (both `localStorageStore` and `memoryStore` do). + +**Note**: This feature is disabled when providing the `getStoreKey` prop. + +```tsx +} +/> +``` + ### `notification` When `` component applies the changes from the store to a form, react-admin informs users with a notification. diff --git a/docs_headless/src/content/docs/useAutoPersistInStore.md b/docs_headless/src/content/docs/useAutoPersistInStore.md index 2cd6ab70627..cf63553a433 100644 --- a/docs_headless/src/content/docs/useAutoPersistInStore.md +++ b/docs_headless/src/content/docs/useAutoPersistInStore.md @@ -74,6 +74,7 @@ It works both on create and edit forms. | --------------------- | -------- | ----------- | ------------------------------------ | ------------------------------------ | | `notification` | Required | `ReactNode` | - | A Notification element. | | `getStoreKey` | - | `function` | - | Function to use your own store key. | +| `maxAge` | - | `number` | - | The age in seconds before a stored value is removed from the store | ### `getStoreKey` @@ -96,6 +97,21 @@ useAutoPersistInStore({ }); ``` +### `maxAge` + +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. + +**Note**: This feature requires a [Store](https://marmelab.com/ra-core/store/) that implements the `listItems` function (both `localStorageStore` and `memoryStore` do). + +**Note**: This feature is disabled when providing the `getStoreKey` prop. + +```tsx +useAutoPersistInStore({ + maxAge: 10 * 60, // 10 minutes + notification: +}); +``` + ### `notification` When `useAutoPersistInStore` hook applies the changes from the store to a form, react-admin informs users with a notification.