Skip to content

Commit

Permalink
Merge pull request #6449 from WiXSL/docs-samples-fixes
Browse files Browse the repository at this point in the history
[Doc] Fix code examples
  • Loading branch information
fzaninotto authored Jul 19, 2021
2 parents 7b0f852 + 0ec4bee commit 7e07922
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/Architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const themes = { light: lightTheme, dark: darkTheme };

export const ThemeContext = createContext(['light', () => {}])

const ThemeContextProvider = ({ value, children }) => (
const ThemeContextProvider = ({ value, children }) => {
const [theme, setTheme] = useState(value);
return (
<ThemeContext.Provider value={[theme, setTheme]}>
Expand Down
2 changes: 1 addition & 1 deletion docs/Fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ const MyShowLayout = () => (
<div>
<Labeled resource="users" source="name">
<TextField source="name" />
</Label>
</Labeled>
</div>
);
```
Expand Down
7 changes: 5 additions & 2 deletions docs/Resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,16 @@ const App = () => (

## Resource Context

`<Resource>` also creates a `RecordContext`, that gives access to the current resource name to all descendents of the main page components (`list`, `create`, `edit`, `show`).
`<Resource>` also creates a `ResourceContext`, that gives access to the current resource name to all descendents of the main page components (`list`, `create`, `edit`, `show`).

to read the current resource name, use the `useResourceContext()` hook.

For instance, the following component displays the name of the current resource:

```jsx
import * as React from 'react';
import { Datagrid, DateField, TextField, List, useResourceContext } from 'react-admin';

const ResourceName = () => {
const { resource } = useResourceContext();
return <>{resource}</>;
Expand All @@ -143,7 +146,7 @@ const PostList = (props) => (
<TextField source="title" />
<DateField source="published_at" />
</Datagrid>
<>
</>
</List>
)
```
Expand Down
4 changes: 2 additions & 2 deletions packages/ra-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ Instead of wrapping the component under test with the `TestContext` by yourself
It will return the same output as the `render` method from `@testing-library/react` but will add the `dispatch` and `reduxStore` helpers.

```jsx
import { defaultStore } from 'ra-test'
...
import { defaultStore } from 'ra-test';
//...
const { dispatch, reduxStore, ...testUtils } = renderWithRedux(
<MyCustomEditView />,
initialState,
Expand Down

0 comments on commit 7e07922

Please sign in to comment.