In my React (v16.3) app I am rendering date-picker controls using material-ui-pickers library's DatePicker component. This component renders a Material-UI TextField
component. I like to change this so it renders only a Material-UI Input
without the chrome rendered by TextField
.
As I understood one can to this with the DatePickers TextFieldComponent
field (here at the bottom) but I couldn't figure out how to use this field.
<DatePicker
id={name}
TextFieldComponent={...<HOW_TO> ...}
value={value}
onChange={this.handleChange}
disabled={isReadOnly} />
Any ideas how to do this?
Update:
Got one step further by finding the right syntax to use and not its rendering without the chrome (FormControl
, InputLabel
, etc.). But also no DatePicker is opened anymore. Do I have to open it programmatically?
<DatePicker
id={name}
TextFieldComponent={(props) => this.renderInput(props)}
value={value}
onChange={this.handleChange}
disabled={isReadOnly} />
And here is renderInput():
renderInput(props: TextFieldProps): any {
return ( <Input
id={props.id}
value={props.value}
onChange={this.handleChange}
type={'text'}
disabled={props.disabled}
/> );
}