Skip to content

Lodash for underscore - _utils2.default.contains is not a function #1384

Closed
@boomdrak

Description

@boomdrak

Error when using rowSelect with lodash 4.+

When using current version of react-boostrap-table2 i get an error when using the rowSelect function. Loading the datatable crashes and the following error is prompted:

node_modules\react-bootstrap-table-next\lib\src\row-selection\row-consumer.js
line 31,32,33 : _utils2.default.contains is not a function

As this post states, .contain has been swapped for .includes in lodash 4+
mgonto/restangular#1298 (comment)

Simply renaming .contains with .includes in row-consumer.js seems to work and removes the error.

To Reproduce
Steps to reproduce the behavior:

  1. Use the following packages
    "react-bootstrap-table-next": "^4.0.2",
    "lodash": "^4.17.15",
    "underscore": "^1.9.2",
    "webpack": "4.41.0",

  2. In webpack.config i have the following setup:
    resolve: {
    extensions: [ '.js', '.jsx' ],
    modules: [
    path.resolve('./js'),
    path.resolve('./es6'),
    ],
    alias: {
    // Make backbone use lodash instead of underscore
    underscore: 'lodash/'
    }
    },

  3. Create a datatable with prop:
    selectRow={selectRow}

  4. See error in your browser
    row-consumer.js
    line 31,32,33 : _utils2.default.contains is not a function

Edited..
I see that alot of other files uses .contains function also..
So not sure if there is a better fix?

Screenshots
lodash_contains

contains

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