Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

reactjs - material ui lab date picker, Can't resolve '@material-ui/lab/AdapterDateFns'

Can't resolve '@material-ui/lab/AdapterDateFns'

Can't resolve '@material-ui/lab/DateTimePicker'

Can't resolve '@material-ui/lab/LocalizationProvider'

I am getting these errors even after having installed @material-ui/lab

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have a working codesandbox here: https://codesandbox.io/s/youthful-wave-8xjy4

Make sure both @material-ui/core and @material-ui/lab are at version "5.0.0-alpha.24" or above as I ran into the same import errors as you when following the guide at: https://next.material-ui.com/guides/pickers-migration/

// package.json
{
  "dependencies": {
    "@emotion/react": "11.1.5",
    "@emotion/styled": "11.1.5",
    "@material-ui/core": "5.0.0-alpha.24",
    "@material-ui/lab": "5.0.0-alpha.24",
    "date-fns": "2.17.0",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-scripts": "4.0.0"
  },
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...