Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs_headless/src/content/docs/AutoPersistInStoreBase.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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
<AutoPersistInStoreBase
maxAge={10 * 60} // 10 minutes
notification={<AutoPersistNotification />}
/>
```

### `notification`

When `<AutoPersistInStoreBase>` component applies the changes from the store to a form, react-admin informs users with a notification.
Expand Down
16 changes: 16 additions & 0 deletions docs_headless/src/content/docs/useAutoPersistInStore.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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: <AutoPersistNotification />
});
```

### `notification`

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