Skip to content

Calling this.setState in onPageChanged callback breaks pagination #416

Open
@Ignalion

Description

@Ignalion

Calling this.setState in onPageChanged causes react render page on NEXT page changing that makes very weird behavior of the component.

I think root cause may be similar with onSelect one (and managing page # by hand as a workaround resolves the issue, like assign page in callback and pass page: in render)

class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = {page: 1};
        this.onPageChange = this.onPageChange.bind(this);
    }

    onPageChange(page) {
        this.setState({page: page})
    }

    render() {
        const pagination = paginationFactory({
            // page: this.state.page,
            onPageChange: this.onPageChange,
        });
        console.log(this.state.selected);
        return (
        <BootstrapTable pagination={pagination} keyField='id' data={products} columns={columns}/>
        )
    }
}

Uncommenting line in render() resolves the issue but I think it would be good to fix this in component.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions