digitalCoffee digitalCoffee - 2 months ago 35
React JSX Question

Is it possible to make react-bootstrap-pagination always show pagination controls even if the total page count is 1?

I use Kurounin:Pagination for MeteorJS and ReactJS.

Is it possible to make react-bootstrap-pagination always show pagination controls even if the total page count is 1?

Answer

Looking at the source code, it seems that this is not currently possible with that package. Your options are:

  1. Submit an issue or a pull request for the package to include an option to force showing pagination.

  2. "Fake it" by adding custom HTML when there is only one page. This should be pretty close to the markup that the package would produce:

{this.pagination.totalPages() > 1 ?
  <BootstrapPaginator pagination={this.pagination} limit={10} containerClass='text-center' />
:
  <div className="pagination-container">
    <ul className="pagination">
      <li className="disabled">
        <a href="#" className="previous-page" title="Previous page"> &lt; </a>
      </li>
      <li key="page1" className="active">
        <a href="#" className="page-link" title="Go to page 1"> 1 </a>
      </li>
      <li className="disabled">
        <a href="#" className="next-page" title="Next page"> &gt; </a>
      </li>
    </ul>
  </div>
}
Comments