Page 1 of 1

Using a ref to get to an InputText's underlying input element

Posted: 19 Jan 2019, 01:11
by efc
I am trying to use a ref to get to the underlying input element of an InputText component. I used this.textFieldRef = React.createRef() to set up the ref, and then the attribute ref={this.textFieldRef} to hook it up. Yet in the componentDidMount I cannot use this.textFieldRef.current.select() because select() is not a function available for that object. So somehow, InputText is not returning the underlying HTMLInputElement.

Does anyone know how I can get from a ref to something that allows me to `select()` the text in the InputText element?

Re: Using a ref to get to an InputText's underlying input element

Posted: 22 Jan 2019, 12:40
by merve7
Hi,
Please, could you send the complete code?