Why does MUI DatePicker prevent rendering in my project (working sandbox MRE included?)

Viewed 145

I created a codesandbox with a minimal working implementation of MUI's Datepicker:

https://codesandbox.io/s/proud-pond-fb4rm?file=/src/App.js

*Edited to add my index.tsx:

import React from 'react';
import ReactDOM from 'react-dom';
import {DatePicker, LocalizationProvider} from "@mui/lab";
import {TextField} from "@mui/material";
import AdapterDateFns from "@mui/lab/AdapterDateFns";

ReactDOM.render(
  <LocalizationProvider dateAdapter={AdapterDateFns}>
    <DatePicker
      renderInput={(props) => <TextField {...props} />}
      value={null}
      onChange={() => null}
    />
  </LocalizationProvider>
  , document.getElementById('root')
)

This implementation throws errors in my project (prevents rendering), although I have the same versions installed. I linked my package-lock file for good measure in case I'm wrong.

Clearly not a bug, and seemingly not a mismatch in package versions, what else could be causing this?

package-lock.json

screenshot of errors thrown

1 Answers

As suspected, the clue was in my package-lock.json. Note to self: Always a good idea to have a look there when issue has been isolated and confirmed unique to a given project!

I had two different versions of @date-io/date-fns installed:

  • 1.x.x (entry in package-json)
  • 2.x.x (installed as dependency)
Related