React Admin - 过滤器组件中的按钮显示两次?
React Admin - Button in the filter component displays twice?
我在过滤器组件中实现了一个清除按钮。清除按钮按预期工作,但该按钮在页面中显示两次。
这是代码
import * as React from 'react';
import { List, Datagrid, TextField, ReferenceField, NumberField, DateField } from 'react-admin';
import { Filter, ReferenceInput, SelectInput, TextInput, DateInput } from 'react-admin';
import Button from '@material-ui/core/Button';
const FilterComponent = props => (
<div>
<Filter {...props} >
<TextInput
label="Search"
source="name"
alwaysOn
/>
<DateInput source="start_date" alwaysOn />
<DateInput source="end_date" alwaysOn />
</Filter>
<Button id="clearButton" variant="outlined" onClick={() => props.setFilters({})}>Clear fields</Button>
</div>
);
export const ProjectList = props => (
<List {...props} filters={<FilterComponent />}>
<Datagrid rowClick="edit">
// Here is the fields
</Datagrid>
</List>
);
但问题是按钮在过滤器组件中显示了两次
请分享您的答案。提前致谢
当 props.context === 'button'
时,您应该隐藏按钮
我在过滤器组件中实现了一个清除按钮。清除按钮按预期工作,但该按钮在页面中显示两次。
这是代码
import * as React from 'react';
import { List, Datagrid, TextField, ReferenceField, NumberField, DateField } from 'react-admin';
import { Filter, ReferenceInput, SelectInput, TextInput, DateInput } from 'react-admin';
import Button from '@material-ui/core/Button';
const FilterComponent = props => (
<div>
<Filter {...props} >
<TextInput
label="Search"
source="name"
alwaysOn
/>
<DateInput source="start_date" alwaysOn />
<DateInput source="end_date" alwaysOn />
</Filter>
<Button id="clearButton" variant="outlined" onClick={() => props.setFilters({})}>Clear fields</Button>
</div>
);
export const ProjectList = props => (
<List {...props} filters={<FilterComponent />}>
<Datagrid rowClick="edit">
// Here is the fields
</Datagrid>
</List>
);
但问题是按钮在过滤器组件中显示了两次
请分享您的答案。提前致谢
当 props.context === 'button'