React DatePicker Issue in MS Edge

230 views Asked by At

I have built a react app which is working fine in Chrome, however due to "Request time out" issue only in Chrome and not in Edge, users started using app in Edge. However in Edge, react datepicker is throwing "RangeError: Invalid time value". This is working fine in Chrome. I am using APi to pull data which contains date as well. When I am filling the form with API data it is failing in MS Edge while working fine in Chrome.

//function to set value to state variable
valuesToBeCopied[prevItem.LABEL_CODE] = prevItem[selectedColumn];
      if (prevItem.LABEL_CODE.includes("DATE") && prevItem[selectedColumn] != "NA") {
        dateFieldVals[prevItem.LABEL_CODE] =
          prevItem[selectedColumn] && new Date(prevItem[selectedColumn]);
      }
    });
    this.setState({
      userEnteredInputs: { ...valuesToBeCopied },
      dateFields: { ...dateFieldVals },
      percentFields: {...percentFieldVals},
    });
//It works fine till this point and after this function ends it throws RangeError: Invalid time value
                
                
                
               return (
          <Datepicker
            name={model.LABEL_CODE}
            ref={this.firstErrorElement ? null : this.firstErrorElement}
            selected={this.state.dateFields[model.LABEL_CODE] || ""}
            dateFormat="dd-MMM-yyyy"
            disabled={this.getFieldDisableStatus()}
            className="txtSize"
            autoComplete="off"
            onChange={(value, labelcode) =>
              this.handleDateChange(value, model.LABEL_CODE)
            }
          ></Datepicker>
          
      

Has anybody faced this issue, please help as I have tried many localstring, ISOString, but no change at all.

0

There are 0 answers