Datepicker doesn't work


Topic: Datepicker doesn't work

Kaherdino pro premium priority asked 3 years ago

Expected behavior The datepicker should change the date on confirm

Actual behavior There is no date selected on the datepicker

I want to use Datepicker to allow my customer to find a foodtruck where there is. So every time I choose a new date, it should requery the foodtrucks available on this date. But actually, it's not working, there is note date selected and no new query on date change.

Here is my datepicker:

<MDBDatepicker
          className="kr-datepicker"
          monthsFull={monthsFull}
          monthsShort={monthsShort}
          weekdaysFull={weekdaysFull}
          weekdaysShort={weekdaysShort}
          weekdaysNarrow={weekdaysNarrow}
          cancelBtnText="Annuler"
          clearBtnText="Effacer"
          format="dd/mm/yyyy"
          min={new Date(year, month - 1, day - 1)}
          value={date}
          inputToggle
          inputStyle={{ width: "8rem" }}
          labelText="Date"
          title="Seul les dates avec des foodtrucks sont sélectionnable"
          setValue={setDate}
          // onChange={handleDatepicker}
          //Filter to show only date with reservations
          filter={function filterFunction(date) {
            const formatDate = formatDateIsoToServer(date);
            if (
              datesWithReservations &&
              datesWithReservations.includes(formatDate)
            ) {
              return true;
            }
            return false;
          }}
        />

Is it right to setValue ?

You can check my website : https://www.foodtruck-point.ch/

Please help me, it's urgent !


We have updated the Datepicker in the 3.0.0 patch. value and setValue props have been removed. If you want to control the Datepicker, remove value and setValue props and add the onChange property. Here is example:

        const [datepicker, setDatepicker] = useState('');

        <MDBDatepicker
              className='kr-datepicker'
              cancelBtnText='Annuler'
              clearBtnText='Effacer'
              format='dd/mm/yyyy'
              inputToggle
              inputStyle={{ width: '8rem' }}
              labelText='Date'
              title='Seul les dates avec des foodtrucks sont sélectionnable'
              onChange={(date) => setDatepicker(date)}
       />

Kaherdino pro premium priority commented 3 years ago

Thanks for you answer.

But, how can I prevent breaking update to append ? Because I'm using the mdb-pro-react it with this package : db-react-ui-kit": "git+https://oauth2:MYSERET-6@git.mdbootstrap.com/mdb/react/mdb5/prd/mdb5-react-ui-kit-pro-essential",

So it's auto update and in my example, it broke...


Wojciech Staniszewski staff commented 3 years ago

I don't really understand your problem. Could you explain this auto-update?


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB React
  • MDB Version: MDB5 3.0.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows
  • Provided sample code: No
  • Provided link: Yes