react-bootstrap-table / react-bootstrap-table2

Next Generation of react-bootstrap-table
https://react-bootstrap-table.github.io/react-bootstrap-table2/
MIT License
1.27k stars 430 forks source link

Warning: Using UNSAFE_componentWillReceiveProps #1530

Open rlutsky042919 opened 3 years ago

rlutsky042919 commented 3 years ago

Describe the bug got this error in console: Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.

Please update the following components: EditingCell

To Reproduce Steps to reproduce the behavior:

  1. install both import BootstrapTable from 'react-bootstrap-table-next'; import cellEditFactory, { Type } from 'react-bootstrap-table2-editor'; 2.set up Bootstrap Table component as return ( <BootstrapTable keyField='id'
    data={ rows } columns={ columns } bootstrap4={true} // striped noDataIndication={noDataIndication} hover // rowEvents={rowEvents} selectRow={ selectRow } cellEdit={cellEdit} /> );

  2. Set up functions to handle row selection and checkboxes: function handleOnSelect(row, isSelect, rowIndex, e, id) { console.log("ROW ID: ", id) if (isSelect === true) { setSelectedStrategy(() => ({ ...selectedStrategy, id}));

    } else { setSelectedStrategy(() => (selectedStrategy.filter(x => x !== row.id) )); } }

    function handleOnSelectAll(isSelect, rows){ const ids = rows.map(r => r.id); if (isSelect) { setSelectedStrategy(() => ({ selectedStrategy: ids })); } else { setSelectedStrategy(() => ({ selectedStrategy: [] })); } }

    const selectRow = { mode: 'checkbox', clickToSelect: true, clickToEdit: true, onSelect: handleOnSelect, onSelectAll: handleOnSelectAll // Click to edit cell also } const cellEdit = cellEditFactory({ mode: 'click', blurToSave: true, selectionRenderer: ({ mode, rowIndex, ...rest }) => ( <input type={mode} id={row${rowIndex + 1}} {...rest} /> ),

    }) ``

  3. See error image

  4. also see that ALL checkboxes are checked whenever click into ANY row.
    codesandbox Please give a simple and minimal example on https://codesandbox.io so that we can reproduce it easily and handle it effectively

Is the Editing Cell warning causing the issues with the checkboxes? I am really liking the library so far.

jslmariano commented 2 years ago

+1

isherwood commented 2 years ago

Duplicates #1308.