Skip to content

Commit 52be3f6

Browse files
committed
Customize the Edit view title with a title component instead of the id
1 parent c027d7f commit 52be3f6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Add support for post create.
1+
// Customize the Edit view title with a title component instead of the id
22
// https://marmelab.com/react-admin/Tutorial.html
33

44
import React from 'react';

src/posts.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import React from 'react';
22
import { List, Datagrid, TextField, ReferenceField, EditButton, Edit, SimpleForm, ReferenceInput, SelectInput, TextInput, DisabledInput, LongTextInput, Create } from 'react-admin';
33

4+
const PostTitle = ({ record }) => {
5+
return <span>Post {record ? `"${record.title}"` : ''}</span>
6+
}
7+
48
export const PostList = props => (
59
<List {...props}>
610
<Datagrid>
@@ -15,7 +19,7 @@ export const PostList = props => (
1519
)
1620

1721
export const PostEdit = props => (
18-
<Edit {...props}>
22+
<Edit title={<PostTitle />} {...props}>
1923
<SimpleForm>
2024
<DisabledInput source="id" />
2125
<ReferenceInput source="userId" reference="users">

0 commit comments

Comments
 (0)