[英]Passing custom data in List in react-admin
我在組件中有數據,並希望在react-admin的[List][1]
組件中發送數據。 有沒有一種方法可以在列表組件中發送數據
<List { ...props } data={listData} />
數據來自一個基於另一個API調用的API(該API是依賴的)。 因此,我無法在GET_LIST
調用API。
這就是我在組件中調用API,然后決定將props中的數據傳遞給[List][1]
組件的原因。
https://marmelab.com/react-admin/List.html#actions
您可以使用以下動作道具來控制和更改流/數據
const PostActions = ({
bulkActions,
basePath,
currentSort,
displayedFilters,
exporter,
filters,
filterValues,
onUnselectItems,
resource,
selectedIds,
showFilter,
total
}) => (
<CardActions>
{bulkActions && React.cloneElement(bulkActions, {
basePath,
filterValues,
resource,
selectedIds,
onUnselectItems,
})}
{filters && React.cloneElement(filters, {
resource,
showFilter,
displayedFilters,
filterValues,
context: 'button',
}) }
<CreateButton basePath={basePath} />
<ExportButton
disabled={total === 0}
resource={resource}
sort={currentSort}
filter={filterValues}
exporter={exporter}
/>
<RefreshButton />
{/* Add your custom actions */}
<Button color="primary" onClick={customAction}>Custom Action</Button>
</CardActions>
);
export const PostList = (props) => (
<List {...props} actions={<PostActions />}>
...
</List>
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.