reactjs – Unable to use material-ui-pickers in React js web application

reactjs – Unable to use material-ui-pickers in React js web application

Refer the official documentation

You need install and pass utils. Firstly install utils for your library:

npm install date-fns @date-io/date-fns

Then pass them to the utils provider

import React, { useState } from react;
import DateFnsUtils from @date-io/date-fns; // import
import { DatePicker, MuiPickersUtilsProvider } from @material-ui/pickers;

function App() {
  const [selectedDate, handleDateChange] = useState(new Date());

  return (
    <MuiPickersUtilsProvider utils={DateFnsUtils}>
      <DatePicker value={selectedDate} onChange={handleDateChange} />
    </MuiPickersUtilsProvider>
  );
}

Here is sandbox to play aroung 🙂

You need install and pass utils. Firstly install utils for your library:

npm i @date-io/[email protected] date-fns

or

npm i @date-io/[email protected] moment

or

npm i -s @date-io/[email protected] luxon

or

npm i -s @date-io/[email protected] dayjs

(The @date-io library release a new version v2 thats break this module.

Please update docs and require install only version 1.X from @date-io in the meantime.)

reactjs – Unable to use material-ui-pickers in React js web application

Leave a Reply

Your email address will not be published.