Skip to content

Commit d4556ff

Browse files
committed
update preferences
1 parent 22c4b2e commit d4556ff

File tree

4 files changed

+26
-40
lines changed

4 files changed

+26
-40
lines changed

docs_headless/src/content/docs/preferences/useRemoveFromStore.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
---
2-
layout: default
32
title: "useRemoveFromStore"
43
---
54

6-
# `useRemoveFromStore`
7-
8-
This hook allows to remove a value from the [Store](./Store.md).
5+
This hook allows to remove a value from the [Store](../guides/Store.md).
96

107
## Syntax
118

129
```jsx
13-
import { useRemoveFromStore } from 'react-admin';
10+
import { useRemoveFromStore } from 'ra-core';
1411

1512
const remove = useRemoveFromStore();
1613
remove(key);
@@ -26,22 +23,21 @@ remove();
2623
## Example
2724

2825
```jsx
29-
import { useRemoveFromStore } from 'react-admin';
30-
import { Button } from '@mui/material';
26+
import { useRemoveFromStore } from 'ra-core';
3127

3228
const ResetPreferences = () => {
3329
const removeItem = useRemoveFromStore();
3430
return (
3531
<>
36-
<Button onClick={() => removeItem('sidebar.open')}>
32+
<button onClick={() => removeItem('sidebar.open')}>
3733
Reset sidebar
38-
</Button>
39-
<Button onClick={() => removeItem('locale')}>
34+
</button>
35+
<button onClick={() => removeItem('locale')}>
4036
Reset locale
41-
</Button>
42-
<Button onClick={() => removeItem('theme')}>
37+
</button>
38+
<button onClick={() => removeItem('theme')}>
4339
Reset theme
44-
</Button>
40+
</button>
4541
</>
4642
);
4743
};
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
---
2-
layout: default
32
title: "useResetStore"
43
---
54

6-
# `useResetStore`
7-
8-
This hook allows to empty the [Store](./Store.md). React-admin uses it at logout.
5+
This hook allows to empty the [Store](../guides/Store.md). React-admin uses it at logout.
96

107
## Syntax
118

129
```jsx
13-
import { useResetStore } from 'react-admin';
10+
import { useResetStore } from 'ra-core';
1411

1512
const reset = useResetStore();
1613
reset();
@@ -19,14 +16,14 @@ reset();
1916
## Example
2017

2118
```jsx
22-
import { useResetStore, Button } from 'react-admin';
19+
import { useResetStore } from 'ra-core';
2320

2421
const ResetButton = () => {
2522
const reset = useResetStore();
2623
return (
27-
<Button onClick={() => reset()}>
24+
<button onClick={() => reset()}>
2825
Reset store
29-
</Button>
26+
</button>
3027
);
3128
};
3229
```

docs_headless/src/content/docs/preferences/useStore.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
---
2-
layout: default
32
title: "useStore"
43
storybook_path: ra-core-store-usestore--basic
54
---
65

7-
# `useStore`
8-
9-
This hook allows to read and write from the [Store](./Store.md). Stored values are available globally and are persisted between page reloads.
6+
This hook allows to read and write from the [Store](../guides/Store.md). Stored values are available globally and are persisted between page reloads.
107

118
## Syntax
129

1310
```jsx
14-
import { useStore } from 'react-admin';
11+
import { useStore } from 'ra-core';
1512

1613
const [value, setValue] = useStore(key, defaultValue);
1714
```
@@ -34,23 +31,22 @@ When one component calls `setValue` on a key, all the components that read the s
3431
## Example
3532

3633
```jsx
37-
import { List, DataTable } from 'react-admin';
34+
import { ListBase } from 'ra-core';
3835

3936
const PostList = () => {
4037
const [density] = useStore('posts.list.density', 'small');
4138

4239
return (
43-
<List>
44-
<DataTable size={density}>
40+
<ListBase>
41+
<div style={{ padding: density === 'small' ? '0.5em' : '1em' }}>
4542
...
46-
</DataTable>
47-
</List>
43+
</div>
44+
</ListBase>
4845
);
4946
}
5047

5148
// anywhere else in the app
52-
import { useStore } from 'react-admin';
53-
import { Button } from '@mui/material';
49+
import { useStore } from 'ra-core';
5450

5551
const ChangeDensity = () => {
5652
const [density, setDensity] = useStore('posts.list.density', 'small');
@@ -61,9 +57,9 @@ const ChangeDensity = () => {
6157
};
6258

6359
return (
64-
<Button onClick={changeDensity}>
60+
<button onClick={changeDensity}>
6561
Change density (current {density})
66-
</Button>
62+
</button>
6763
);
6864
};
6965
```
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
---
2-
layout: default
32
title: "useStoreContext"
43
---
54

6-
# `useStoreContext`
7-
8-
This hook allows to access the global [Store](./Store.md).
5+
This hook allows to access the global [Store](../guides/Store.md).
96

107
It should not be used directly. Prefer the specialized hooks (`useStore`, `useResetStore`, `useRemoveFromStore`) instead.
118

129
## Syntax
1310

1411
```jsx
15-
import { useStoreContext } from 'react-admin';
12+
import { useStoreContext } from 'ra-core';
1613

1714
const store = useStoreContext();
1815
```

0 commit comments

Comments
 (0)