Skip to content

Commit

Permalink
[Doc] Remove <ShowBase emptyWhileLoading> from the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
slax57 committed Dec 16, 2024
1 parent bdf5cce commit 8c01e20
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions docs/ShowBase.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import { Grid } from '@mui/material';
import StarIcon from '@mui/icons-material/Star';

const BookShow = () => (
<ShowBase emptyWhileLoading>
<ShowBase>
<Grid container spacing={2} sx={{ margin: 2 }}>
<Grid item xs={12} sm={6}>
<TextField label="Title" source="title" />
Expand Down Expand Up @@ -117,20 +117,6 @@ const PostShow = () => (
);
```

## `emptyWhileLoading`

By default, `<ShowBase>` renders its child component even before the `dataProvider.getOne()` call returns. If you use `<SimpleShowLayout>` or `<TabbedShowLayout>`, this isn't a problem as these components only render when the record has been fetched. But if you use a custom child component that expects the record context to be defined, your component will throw an error.

The `<ShowBase emptyWhileLoading>` prop provides a convenient shortcut for that use case. When enabled, `<ShowBase>` won't render its child until the record is loaded.

```jsx
const BookShow = () => (
<ShowBase emptyWhileLoading>
...
</ShowBase>
);
```

## `id`

By default, `<ShowBase>` deduces the identifier of the record to show from the URL path. So under the `/posts/123/show` path, the `id` prop will be `123`. You may want to force a different identifier. In this case, pass a custom `id` prop.
Expand Down

0 comments on commit 8c01e20

Please sign in to comment.