question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can I safely use Input.prototype.inputRef?

See original GitHub issue

Hello!

I need to get a DOM node from Input component. Not for focus only. For example I need to call input.setSelectionRange.

So. I have not found how to get DOM node in the documentation. But I have found inputRef in the code. May be it will be worth to add this property as “public” API in the documentation and TS definitions (like in this https://github.com/Semantic-Org/Semantic-UI-React/issues/1970)?

At the moment I can get input element only with findDOMNode that is not a good React practice.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
layershiftercommented, Aug 18, 2017

#1879 will introduce innerRef for all components

0reactions
layershiftercommented, Aug 18, 2017
<Form.Field innerRef={(div: HTMLDividerElement) => void} />
<Form.Input innerRef={(div: HTMLDividerElement) => void} />

Because, Form.Field renders div as root element.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I use ref in TextField - material ui - Stack Overflow
String refs are deprecated and material-ui does not support using them. ... a ref to the <input /> element you should use the...
Read more >
Use a Refs in React to Create an Upload Component
We will first create the file input and then add a custom button component. The button will trigger the file upload functionality of...
Read more >
How to Use React to Set the Value of an Input | Pluralsight
This guide will cover two different approaches to setting values of input elements. Controlled Input Approach. Form controls in React are a bit ......
Read more >
React Tutorial #10 - Input Refs - YouTube
Hey, in this React tutorial for beginners, I'll introduce you to input Refs and how we can use them to reach into the...
Read more >
How to use React createRef - LogRocket Blog
Learn how to use the React.createRef() method and useRef Hook in React to simplify creating refs and interact with the HTML DOM.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found