Getting Error while using DatePicker component
See original GitHub issueEnvironment
Tech | Version |
---|---|
material-ui-pickers | 1.0.0-rc.3 |
material-ui | 1.0.0-beta.35 |
React | 15.6.1 |
Browser | Chrome |
Platform | Windows 7 |
Steps to reproduce
I am using following code snippet
import React, { Fragment, PureComponent } from ‘react’; import { DatePicker } from ‘material-ui-pickers’; import withStyles, { WithStyles, StyleRulesCallback } from ‘material-ui/styles/withStyles’; import MuiPickersUtilsProvider from ‘material-ui-pickers/utils/MuiPickersUtilsProvider’; import DateFnsUtils from ‘material-ui-pickers/utils/date-fns-utils’; type Props = { value:string; label:string; changeHandler(event:any):void; }
type State = {
selectedDate:any
}
export default class DateSelector extends PureComponent<Props & WithStyles<‘root’>, State> {
state = {
selectedDate: new Date(),
}
handleDateChange = (date) => { this.setState({ selectedDate: date }); }
render() { const { selectedDate } = this.state;
return (
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<div>
<DatePicker
label="Basic example"
value={selectedDate}
onChange={this.handleDateChange}
animateYearScrolling={false}
/>
</div>
</MuiPickersUtilsProvider>
);
} }
Expected behavior
The code snippet should render a Date picker
Actual behavior
Throwing following error
Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in. Check the render method of ModalWrapper
.
at invariant (react-dom.js:17896)
at ReactCompositeComponentWrapper.instantiateReactComponent [as _instantiateReactComponent] (react-dom.js:16037)
at ReactCompositeComponentWrapper.performInitialMount (react-dom.js:4821)
at ReactCompositeComponentWrapper.mountComponent (react-dom.js:4712)
at Object.mountComponent (react-dom.js:11542)
at ReactCompositeComponentWrapper.performInitialMount (react-dom.js:4825)
at ReactCompositeComponentWrapper.mountComponent (react-dom.js:4712)
at Object.mountComponent (react-dom.js:11542)
at ReactCompositeComponentWrapper.performInitialMount (react-dom.js:4825)
at ReactCompositeComponentWrapper.mountComponent (react-dom.js:4712)
at Object.mountComponent (react-dom.js:11542)
at ReactDOMComponent.mountChildren (react-dom.js:10429)
at ReactDOMComponent._createInitialChildren (react-dom.js:6164)
at ReactDOMComponent.mountComponent (react-dom.js:5983)
at Object.mountComponent (react-dom.js:11542)
at ReactCompositeComponentWrapper.performInitialMount (react-dom.js:4825)
Live example
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Hi @dmtrKovalenko
It works fine after upgrading to version : 16.2.0. But a new issue has cropped up now. All the icons pertaining to calendar, keyboard_arrow_left and keyboard_arrow_right are not being replaced by actual images, rather I see their corresponding text. Attached are the snapshots.
Note: I am not able to replicate the issue in Sandbox

Can second the same issue happened to me: Heres an example, i might have time to create a sandbox later:
Heres app.jsx
Heres where its used