TextFilter contains an input of type text with both value and defaultValue props.
I am trying to implement remote filtering. My Table Component works fine, but I am getting a warning:
Warning: TextFilter contains an input of type text with both value and defaultValue props. Input elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://fb.me/react-controlled-components
This is my Component:
const filter = textFilter({
delay: 1000
});
const columns = [
{
text: 'Company Name',
dataField: 'name',
filter
},
{
text: 'Email',
dataField: 'email',
filter
}
];
class CompaniesTable extends Component {
componentWillMount() {
//fetching table data
this.props.fetchCompanies(0, 5);
}
onTableChange = (type, {filters, page, sizePerPage}) => {
// some code that generates a proper url and calls this.props.fetchCompanies
// to get new data and update the table
};
render() {
const {data = [], page, sizePerPage, totalElements} = this.props;
return (
<BootstrapTable keyField='id'
remote={{filter: true}}
data={data}
columns={this.columns}
filter={filterFactory()}
onTableChange={this.onTableChange}/>
)
}
}
function mapStateToProps(state) {
return {
data: getCompaniesTableData(state),
page: getCompaniesTablePage(state),
sizePerPage: getCompaniesTableSize(state),
totalElements: getCompaniesTableTotalElements(state)
};
}
export default withRouter(connect(mapStateToProps, {fetchCompanies})(CompaniesTable));
How can I fix this? Thanks in advance.
The error probably has nothing to do with your code. It shows up in the storybook examples. I think this requires a fix in react-bootstrap-table2.
@anikakalbrun @makenova I'll check this out and fix it ASAP
Will be fixed it in next week
New Release: https://react-bootstrap-table.github.io/react-bootstrap-table2/blog/2018/02/14/version-bump.html
Let me know if theres any problem, thanks