react-bootstrap-table2 icon indicating copy to clipboard operation
react-bootstrap-table2 copied to clipboard

TextFilter contains an input of type text with both value and defaultValue props.

Open anikakalbrun opened this issue 8 years ago • 4 comments

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.

anikakalbrun avatar Feb 06 '18 18:02 anikakalbrun

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.

makenova avatar Feb 07 '18 00:02 makenova

@anikakalbrun @makenova I'll check this out and fix it ASAP

AllenFang avatar Feb 10 '18 05:02 AllenFang

Will be fixed it in next week

AllenFang avatar Feb 10 '18 09:02 AllenFang

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

AllenFang avatar Feb 14 '18 08:02 AllenFang