首页 > 解决方案 > React-Bootstrap Pagination component adds a random (current) to the current page

问题描述

This is my pagination component

class PaginationComponent extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            maxPage: this.props.maxPage,
            activePage: this.props.activePage
        }
    }

    render() {
        const items = [];
        for (let number = 1; number <= this.state.maxPage; number++) {
            items.push(
                <Pagination.Item key={number} active={number === this.state.activePage}>
                    {number}
                </Pagination.Item>
            );
        }
        return (
            <Pagination>
                {items}
            </Pagination>
        )
    }
}

and I'm using it like so

                <div>
                    <PaginationComponent maxPage={5} activePage=1/>
                </div>

enter image description here

but somehow it's rendering this instead 1(current), is this an option that I have to disable? I haven't been able to find anything regarding this behavior.

标签: paginationreact-bootstrap

解决方案


activeLabel = ""道具添加到Pagination.Item


推荐阅读