Skip to content

React warning when there's only one page to show in v3.5.0 #1518

Closed
@alejo90

Description

@alejo90

I upgraded to 3.5.0 and now a React warning stating Each child in an array or iterator should have a unique "key" prop. Check the render method of PaginationList` now appears when there's only one page to show. I traced the problem to here (https://github.com/AllenFang/react-bootstrap-table/blob/master/src/pagination/PaginationList.js#L123):

return (
  <div className='row' style={ { marginTop: 15 } }>
    {
      content ||
        [ (
          <div className='col-md-6 col-xs-6 col-sm-6 col-lg-6'>
            { total }{ sizePerPageList.length > 1 ? dropdown : null }
          </div>
          ), (
          <div style={ { display: hidePageList } }
            className='col-md-6 col-xs-6 col-sm-6 col-lg-6'>
            { pageBtns }
          </div>
        ) ]
    }
  </div>
);

When content is undefined, the div elements in the array are rendered. Since it's an array, each div element has to have a key.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions