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.

React has a ref property for all components, that refers to the DOM element. Any plans to add this one on Preact?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:8
  • Comments:49 (21 by maintainers)

github_iconTop GitHub Comments

developitcommented, Feb 23, 2016

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 🌈

developitcommented, Jan 13, 2017

@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.

Read more comments on GitHub >

github_iconTop 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 >

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 Post

No results found

github_iconTop Related Hashnode Post

No results found