1
- // Adding custom styles with material-ui provided JSS
1
+ // Have ListGuesser suggest how to handle the relationship between Users and Posts
2
2
// https://marmelab.com/react-admin/Tutorial.html
3
3
4
4
/*
5
5
6
- Guessed List from last commit (now used in this commit, and imported from ./users.js). Browser shows same list of users:
6
+ Guessed List for posts from the posts API endpoint:
7
+
8
+ Guessed List:
9
+
10
+ export const PostList = props => (
11
+ <List {...props}>
12
+ <Datagrid rowClick="edit">
13
+ <ReferenceField source="userId" reference="users"><TextField source="id" /></ReferenceField>
14
+ <TextField source="id" />
15
+ <TextField source="title" />
16
+ <TextField source="body" />
17
+ </Datagrid>
18
+ </List>
19
+ );
20
+
21
+ Guessed List for users from prior commit (now used in this commit, and imported from ./users.js). Browser shows same list of users:
7
22
8
23
export const UserList = props => (
9
24
<List {...props}>
@@ -17,20 +32,21 @@ export const UserList = props => (
17
32
<TextField source="website" />
18
33
<TextField source="company.name" />
19
34
</Datagrid>
20
- </List> );
35
+ </List>
21
36
);
22
37
23
38
*/
24
39
25
40
import React from 'react' ;
26
- import { Admin , Resource } from 'react-admin' ;
41
+ import { Admin , Resource , ListGuesser } from 'react-admin' ;
27
42
import { UserList } from './users'
28
43
import jsonServerProvider from 'ra-data-json-server' ;
29
44
30
45
const dataProvider = jsonServerProvider ( 'http://jsonplaceholder.typicode.com' ) ;
31
46
32
47
const App = ( ) => (
33
48
< Admin dataProvider = { dataProvider } >
49
+ < Resource name = "posts" list = { ListGuesser } />
34
50
< Resource name = "users" list = { UserList } />
35
51
</ Admin >
36
52
)
0 commit comments