Add ref property
See original GitHub issueReact has a ref
property for all components, that refers to the DOM element. Any plans to add this one on Preact?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:8
- Comments:49 (21 by maintainers)
Top Results From Across the Web
Refs and the DOM - React
Adding a Ref to a DOM Element ... React will assign the current property with the DOM element when the component mounts, and...
Read more >A complete guide to React refs - LogRocket Blog
Learn how to use React refs, and why it's important to use them only when React can't handle a function call through its...
Read more >Working with refs in React | CSS-Tricks
createRef () is a new API that shipped with React 16.3. You can create a ref by calling React.createRef() and attaching a React...
Read more >Refs in React js - Topcoder
To add ref to a DOM element we need to pass the ref attribute and in this case, the 'current' property will be...
Read more >How to Use React Refs - Ross Bulat - Medium
Refs are created using React.createRef() , and are assigned to class properties. In the above example the ref is named myRef , which...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
100% voted for function refs only, so that seals the deal.
4.0.1
now (only) supports function refs. There are also now some decent tests 🌈@JeromeDane not sure what you are looking for an update on… If you mean an update on support for the
ref
prop, it’s already been supported for almost a year (when this issue was closed, in Feb of 2016). Support for String refs will never be included in Preact’s core since they are deprecated and a poor design that impacts performance. They have always been available in preact-compat, however.There is also a standalone helper utility called linkRef that emulates React’s String ref behaviour in a way that doesn’t fall victim to the same issues.