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.

Confusion around obtaining a ref to a Button/IconButton element

See original GitHub issue

When reading the documentation, I find it confusing that IconButton (doc) is documented to have a buttonRef and a rootRef props. What’s the difference between those two? Also, why Button (doc) is documented to have none of those? And then ButtonBase (doc) has rootRef but no buttonRef.

Additionally, I find that in the release notes of v1.0.0-beta.27 rootRef is being removed from some components (although I don’t see any button component being mentioned there).

Finally, while using these components under the latest release (beta.30) which is already after beta.27, I get buttons to work using rootRef, even when they don’t have this prop documented. And I get icon buttons to work with buttonRef but not with rootRef, even when they have both documented.

So which one is it?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Jan 29, 2018

I like the buttonRef support for both Button and IconButton. Looking forward to it. Thanks!

Alright. Let’s implement it 😃.

1reaction
gnapsecommented, Jan 29, 2018

Ok, good to know about that other react issue. BTW, that one also does not recommend the use of findDOMNode. So I’m not sure I understand the direction this project is taking in officially recommending its use. Presumably is until React makes its mind about this hostRef thing. I’d still prefer to avoid the currently recommended solution to root refs since definitely all proposals seem to discourage the use findDOMNode.

I like the buttonRef support for both Button and IconButton. Looking forward to it. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Confusion around obtaining a ref to a Button/IconButton element
When reading the documentation, I find it confusing that IconButton (doc) is documented to have a buttonRef and a rootRef props.
Read more >
Refs and the DOM - React
Refs provide a way to access DOM nodes or React elements created in the render method. ... The examples below have been updated...
Read more >
Everything You Need to Know About Refs in React
Short for “reference”, refs are a way to access underlying DOM elements in a React component. There are many reasons why you would...
Read more >
Templating: HTML Behaviors Introduction - Aurelia
An overview of the Aurelia templating engine's custom attribute and custom element functionality, including not only how to create basic versions, ...
Read more >
When to use React's Ref on a DOM node in React
In the code snippet above it is used to get the input value of the input element when you submit the form. When...
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