From 2e2691f96ef25d9b9cbaa0878b0ebd8a945bb9db Mon Sep 17 00:00:00 2001 From: asvarcas Date: Mon, 19 Jul 2021 11:21:40 -0300 Subject: [PATCH 1/2] Fix documentation examples --- docs/Architecture.md | 2 +- docs/Fields.md | 2 +- docs/Resource.md | 5 ++++- packages/ra-test/README.md | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/Architecture.md b/docs/Architecture.md index e75db308fdf..c2697a9435b 100644 --- a/docs/Architecture.md +++ b/docs/Architecture.md @@ -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 ( diff --git a/docs/Fields.md b/docs/Fields.md index a4d71ff8f69..22c5ddb6613 100644 --- a/docs/Fields.md +++ b/docs/Fields.md @@ -1491,7 +1491,7 @@ const MyShowLayout = () => (
- +
); ``` diff --git a/docs/Resource.md b/docs/Resource.md index 985acf971ca..d022f7b55f1 100644 --- a/docs/Resource.md +++ b/docs/Resource.md @@ -130,6 +130,9 @@ 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}; @@ -143,7 +146,7 @@ const PostList = (props) => ( - <> + ) ``` diff --git a/packages/ra-test/README.md b/packages/ra-test/README.md index b6568b52280..8a5522548e3 100644 --- a/packages/ra-test/README.md +++ b/packages/ra-test/README.md @@ -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( , initialState, From 0ec4beef44812df4f5ace4cc30ba089851f6d3c1 Mon Sep 17 00:00:00 2001 From: asvarcas Date: Mon, 19 Jul 2021 11:57:06 -0300 Subject: [PATCH 2/2] Change RecordContext for ResourceContext --- docs/Resource.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Resource.md b/docs/Resource.md index d022f7b55f1..e7fdac279af 100644 --- a/docs/Resource.md +++ b/docs/Resource.md @@ -123,7 +123,7 @@ const App = () => ( ## Resource Context -`` also creates a `RecordContext`, that gives access to the current resource name to all descendents of the main page components (`list`, `create`, `edit`, `show`). +`` 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.