Reputation: 549
I'm trying to change the value of Material-UI
's TextField
when it focuses. It seems that I can do that through inputProps
, but I can't find any example of how to implement that.
Upvotes: 0
Views: 1722
Reputation: 467
add onFocus prop with TextField
<TextField value={this.state.value} onFocus={onFocus} label="Custom CSS" variant="outlined" id="custom-css-outlined-input" />
then handle the onFocus event
const onFocus = () => {
this.setState({
value:'new value'
})
}
it should update the value in the field when focus comes on the text field
Upvotes: 2