Search code examples
reactjsreact-hooksreact-datepicker

React datepicker onchange keypress problem


I use react-datepicker in my project. When I press the key, it completes automatically input. What do I need to change to work correctly like input?

Here is the code.

https://codesandbox.io/s/nifty-hopper-jm4gx


Solution

  • The issue is with customInput, Once you remove it, it will work fine

    <div className="custom-calendar">
      <span className="calendar"></span>
      <DatePicker
        ref={ref}
        name="birthday"
        dateFormat="dd/MM/yyyy"
        disabled={disabled}
        popperPlacement="right-center"
        locale="tr"
        selected={startDate || value}
        showMonthDropdown
        showYearDropdown
        onChange={(date) => onChangePicker(date)}
        yearDropdownItemNumber={100}
        maxDate={addDays(new Date(), 0)}
        scrollableYearDropdown
        autoComplete="off"
      />
    </div>