MUI pickers + date-fns = TypeError: utils.getYearText is not a function
MUI pickers + date-fns = TypeError: utils.getYearText is not a function
我正在使用来自 Material UI:
的 Material-UI V4, Material-UI Date/Time Pickers and date-fns in a new project. My page is pretty simple and I am using the following DateTimePicker
组件
<DateTimePicker
label="Date and time"
inputVariant="outlined"
value={searchDateTime}
disablePast
onChange={handleSearchDateTimeChange}
showTodayButton
fullWidth
disabled={isScanning}
/>
单击日期选择器后,我的应用程序崩溃并出现以下错误:
TypeError: utils.getYearText is not a function
我该如何解决这个问题?
来自 package.json
的版本
"@date-io/date-fns": "^2.11.0",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/pickers": "^3.3.10",
"date-fns": "^2.26.0",
"next": "10.0.5",
"react": "17.0.2",
"react-dom": "17.0.2",
将 @date-io/date-fns
从 2.11.0
降级到 1.3.13
。
来自 the installation guide 个 Material UI 个选择器:
Important: For material-ui-pickers v3 use v1.x version of @date-io adapters.
我正在使用来自 Material UI:
的 Material-UI V4, Material-UI Date/Time Pickers and date-fns in a new project. My page is pretty simple and I am using the followingDateTimePicker
组件
<DateTimePicker
label="Date and time"
inputVariant="outlined"
value={searchDateTime}
disablePast
onChange={handleSearchDateTimeChange}
showTodayButton
fullWidth
disabled={isScanning}
/>
单击日期选择器后,我的应用程序崩溃并出现以下错误:
TypeError: utils.getYearText is not a function
我该如何解决这个问题?
来自 package.json
"@date-io/date-fns": "^2.11.0",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/pickers": "^3.3.10",
"date-fns": "^2.26.0",
"next": "10.0.5",
"react": "17.0.2",
"react-dom": "17.0.2",
将 @date-io/date-fns
从 2.11.0
降级到 1.3.13
。
来自 the installation guide 个 Material UI 个选择器:
Important: For material-ui-pickers v3 use v1.x version of @date-io adapters.