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 431 forks source link

Column formatter called in infinite loop when checkbox selection enabled #724

Closed jafwatt closed 5 years ago

jafwatt commented 5 years ago

I've only just started using this component but I like it a lot. Unfortunately I've already encountered an issue where my column formatter function is getting called in an infinite loop. This only happens when I enable row selection.

Here's my render method:

    render() {

        const columns = [{
          dataField: 'workPackageName',
          text: 'Description'
        },{
          dataField: 'skillsets',
            formatter: this.workPackageSkillsetFormatter,
          text: 'Skillsets'
        }];

        const selectRow = {
          mode: 'checkbox'
        };

        return (
            <div>
                <BootstrapTable 
                    bootstrap4={ true }
                    keyField='workPackageId' 
                    data={ this.state.workPackages } 
                    columns={ columns }
                    selectRow={ selectRow }
                />
            </div>
        );
    }

Here's my column formatter function:

    workPackageSkillsetFormatter() {
        console.log('workPackageSkillsetFormatter');
        return (<span>Foo</span>);
    }

I can provide a screenshot of my browsers console showing the workPackageSkillsetFormatter function being called infinitely.

AllenFang commented 5 years ago

@jafwatt I can not reproduce this issue, can you give me a simple and minimal example here or codesandbox.io? In addition, what is when checkbox selection enabled, you mean you have selectRow with multiple selection? Please give me more information,. thanks

jafwatt commented 5 years ago

Thanks for the quick response @AllenFang. It was a problem with my lifecycle events causing the constant rendering and not anything to do with the table.