我在快递中创建了一个返回客户的休息api。我正在尝试使用休息时管理员在管理面板上显示它们。
我无法显示所有客户,但只显示最后一位客户。我不确定是什么问题。
以下是我的应用代码。
import React, { Component } from 'react';
import { jsonServerRestClient, Admin, Resource } from 'admin-on-rest';
import {UserList} from './users';
class App extends Component {
render() {
console.log({UserList});
return (
<Admin restClient={jsonServerRestClient('http://localhost:8080/api')}>
<Resource name="customer" list={UserList} />
</Admin>
);
}
}
export default App;[enter image description here][1]
下面的是users.js
import React from 'react';
import { List, Datagrid, EmailField, TextField } from 'admin-on-rest';
export const UserList = (props) => (
<List title="All users" {...props}>
<Datagrid>
<TextField source="name" />
<EmailField source="emailId" />
</Datagrid>
</List>
);
但是,无论何时我整合列表,都会显示仅限最后一个客户的详细信息。控制台中还有一个警告
警告:数组或迭代器中的每个子节点都应该有一个唯一的“键”支柱。
Check the render method of `DatagridBody`.
in TableRow (created by DatagridBody)
in DatagridBody (created by shouldUpdate(DatagridBody))
in shouldUpdate(DatagridBody) (created by Datagrid)
in table (created by Table)
in div (created by Table)
in div (created by Table)
in Table (created by Datagrid)
in Datagrid (created by MuiComponent)
in MuiComponent (at users.js:6)
in div (created by List)
in div (created by Card)
in div (created by Paper)
in Paper (created by Card)
in Card (created by List)
in div (created by List)
in List (created by WithPermissionsFilteredChildren)
in WithPermissionsFilteredChildren (created by getContext(WithPermissionsFilteredChildren))
in getContext(WithPermissionsFilteredChildren) (created by TranslatedComponent(getContext(WithPermissionsFilteredChildren)))
in TranslatedComponent(getContext(WithPermissionsFilteredChildren)) (created by Connect(TranslatedComponent(getContext(WithPermissionsFilteredChildren))))
in Connect(TranslatedComponent(getContext(WithPermissionsFilteredChildren))) (at users.js:5)
答案 0 :(得分:0)
这可能是因为当_id
期待admin-on-rest
时您正在使用id
。