Perhaps you could take a state based approach to this, where you would update the state of the component to track the type
of the input field when onFocus
occours by doing something like this:
onFocus={ () => this.setState({ typeOfFocused : 'date' }) }
Doing this would trigger a re-render which in turn would cause the input element's type to switch to date
via the following:
render() {
// Extract typeOfFocused from state
const { typeOfFocused } = this.state
// Render input type with typeOfFocused if present, or as text by default
return (<input placeholder="Date"
type={ typeOfFocused || 'text' }
onFocus={ () => this.setState({ typeOfFocused : 'date' }) }
onBlur={ () => this.setState({ typeOfFocused : '' }) }
id="date">)
}
Here's a working sample