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

UI Components for React
Post Reply
efc
Posts: 1
Joined: 17 Jan 2019, 22:09

19 Jan 2019, 01:11

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?

merve7
Posts: 446
Joined: 12 Sep 2017, 10:44

22 Jan 2019, 12:40

Hi,
Please, could you send the complete code?

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests