Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
boomdrak opened this issue May 26, 2020 · 3 comments
Closed

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

boomdrak opened this issue May 26, 2020 · 3 comments
Assignees

Comments

@boomdrak
Copy link

boomdrak commented May 26, 2020

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

AllenFang added a commit that referenced this issue May 31, 2020
@AllenFang
Copy link
Member

@boomdrak it's an edge case for me actually, but I guess I have a simplest solution. Let me fix it and see if it is work or not.

@AllenFang
Copy link
Member

@boomdrak upgrade react-bootstrap-table-next to newest. Please open another issue if the issue still remain, thanks

@boomdrak
Copy link
Author

Thank you so much, @AllenFang 👍
Works perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants