Skip to content

Cannot read property 'id' of undefined + The above error occurred in the <SelectionProvider> component: #1669

Open
@smchauhan

Description

@smchauhan

Hi Allen,

The bug
I want all these functionalities in single table searching in all fields + paging, it works fine for the first time, but after navigating to another page and searching for something generates error. for your reference have added code snippet and error,

Code Snippet

import paginationFactory, { PaginationProvider, PaginationListStandalone } from 'react-bootstrap-table2-paginator';
import ToolkitProvider, { Search } from 'react-bootstrap-table2-toolkit';
import { tableData } from '../../../data/blog/BlogPostData';

const columns = [
    {   dataField: 'id',        text: 'Id'      },
    {   dataField: 'category',  text: 'Category' }, 
    {   dataField: 'slug',      text: 'Slug'    }, 
    {   dataField: 'posts',     text: 'Posts'   },
    {   dataField: 'date_created',  text: 'Date Created'    },
    {   dataField: 'date_updated',  text: 'Date Updated'    },
];
const options = {
    custom: true,
    paginationSize: 4,
    pageStartIndex: 1,
    firstPageText: 'First',
    prePageText: 'Prev',
    nextPageText: 'Next',
    lastPageText: 'Last',
    nextPageTitle: 'First page',
    prePageTitle: 'Pre page',
    firstPageTitle: 'Next page',
    lastPageTitle: 'Last page',
    showTotal: true,
    totalSize: tableData.length
  };
const contentTable = ({ paginationProps, paginationTableProps }) => (
    <div>
      <ToolkitProvider
        keyField="id"
        columns={ columns }
        data={ tableData}
        search
      >
        {
          toolkitprops => (
            <div className="post-table">              
              <SearchBar { ...toolkitprops.searchProps } className="search-bar m-4" placeholder="Search Post" /> 
              <div className="table-responsive">
                  <BootstrapTable
                selectRow={ selectRow }
                bordered={ false }  
                { ...toolkitprops.baseProps }
                { ...paginationTableProps }
              />
              </div>
            </div>
          )
        }
      </ToolkitProvider>      
      <PaginationListStandalone { ...paginationProps } />      
    </div>
  );

const BlogPost= () => {
return (
        <Fragment>
           <PaginationProvider
             pagination={
                  paginationFactory(options)
              }
             >
              { contentTable }
           </PaginationProvider>
     </Fragment>
    )
};
export default BlogPost;

To Reproduce
Steps that generate errors:

  1. Enter value in Search bar ( It works fine )
  2. Navigate to page 2..3...or X
  3. Again enter value in Search bar ( It generate error with blank screen )
  4. See error below show in my console.

Error Screenshots
If applicable, add screenshots to help explain your problem.

  1. https://prnt.sc/1mt2mvr
  2. https://prnt.sc/1mt2upq
  3. https://prnt.sc/1mt9yhe

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions