react-date-range icon indicating copy to clipboard operation
react-date-range copied to clipboard

utils.js:69 Uncaught TypeError: Cannot read properties of undefined (reading 'findIndex')

Open forgowhisky opened this issue 3 years ago • 2 comments

Subject of the issue

When trying to render the component, the following error occurs:

utils.js:69 Uncaught TypeError: Cannot read properties of undefined (reading 'findIndex')

[BUG] Bug Reproduce Steps

Simply install the package on any react app, import it, and render it with <DateRangerPicker />

[BUG] Expected behaviour

the app to not crash and the date range picker to display

Environment

Package Version: 1.4.0 React version: 17.0.2 Node version: any Browser: chrome

forgowhisky avatar Jun 11 '22 17:06 forgowhisky

You get this error when ranges is malformed, in my case my object was:

{
    "startDate": "2022-06-01T00:00:00.000Z",
    "endDate": "2022-06-29T00:00:00.000Z",
    "key": "selection"
}

when ranges should be

[
    {
        "startDate": "2022-06-01T00:00:00.000Z",
        "endDate": "2022-06-29T00:00:00.000Z",
        "key": "selection"
    }
]

it should be of type array, not object

StanlyLife avatar Jul 30 '22 15:07 StanlyLife

Hey, if you using class componenet you should pass the value onChange like this : this.setState({range:[range.selection]})

aminebya1 avatar Sep 19 '22 13:09 aminebya1