I am new in react, using material-ui date picker in my project , from the documentation here . In this i am using moment.js
the following code in datetimepicker
import React,{ useState } from 'react';
import MomentUtils from 'moment';
import {
DatePicker,
TimePicker,
DateTimePicker,
MuiPickersUtilsProvider,
} from "@material-ui/pickers";
function DateTimePickers() {
const [selectedDate, handleDateChange] = useState(new
Date());
return (
<MuiPickersUtilsProvider utils={MomentUtils}>
<DatePicker value={selectedDate} onChange=
{handleDateChange} />
<TimePicker value={selectedDate} onChange=
{handleDateChange} />
<DateTimePicker value={selectedDate} onChange=
{handleDateChange} />
</MuiPickersUtilsProvider>
);
}
export default DateTimePickers;
but showing error
TypeError: utils.endOfDay is not a function getComparisonMaxDate node_modules/@material-ui/pickers/esm/_helpers/text-field-helper.js:23
20 | return date;
21 | }
22 |
> 23 | return utils.endOfDay(date);
24 | };
25 |
26 | var getComparisonMinDate = function
getComparisonMinDate(utils, strictCompareDates, date) {
Thanks in advance . Help me out of this problem
TypeError: "x" is not a function The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value is not actually a function.
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value is not actually a function. Message TypeError: Object doesn't support property or method {x} (Edge) TypeError: "x" is not a function
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value is not actually a function. What went wrong? It attempted to call a value from a function, but the value is not actually a function. Some code expects you to provide a function, but that didn't happen.
Make sure that Day.js supports the require () function. If it is import -based, you need to maybe change the import to that. So, just try doing the following. Your were trying to call diff () on a string (the output of dayjs ().format ()) rather than a Dayjs object
The import is wrong. It should be:
import MomentUtils from '@date-io/moment';
You can refer to working CodeSandbox demo:https://codesandbox.io/s/material-demo-h3ke7?fontsize=14
Clarification:
I faced the same issue in date picker documentation https://material-ui-pickers.dev/getting-started/installation
install thie version npm i @date-io/[email protected] moment
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With