innerRef support for withTheme() HOC
See original GitHub issueVersion
1.4.4
Reproduction
https://www.webpackbin.com/bins/-KfSbgVyPqFmY7yJYVj0
Steps to reproduce
Style a withTheme()
-wrapped component and try to use the innerRef
callback to grab the wrapped component instance.
Expected Behavior
I would expect the innerRef
callback to resolve to the deeply nested child.
Actual Behavior
The withTheme
HOC instance is returned by innerRef()
and there’s no way to get the wrapped child component.
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (11 by maintainers)
Top Results From Across the Web
Advanced Usage - styled-components
styled-components has full theming support by exporting a <ThemeProvider> wrapper ... Color the border and text with theme.main */ ... Ad hoc theme....
Read more >How I can access to DOM node inside of withStyle component?
I seek in the web and find some GitHub issues pages and try innerRef instead of ref but it doesn't help me. How...
Read more >Breaking changes in v5, part one: styles and themes - MUI
Support for non-ref-forwarding class components in the component prop or as ... The withTheme HOC utility has been removed from the @mui/material/styles ...
Read more >Advanced Guides - Glamorous
You can accomplish this with the innerRef prop. ... glamorous also exports a withTheme higher order component (HOC) so you can access your...
Read more >styled-components | Yarn - Package Manager
... down to descendant component children when using the styled() HOC wrapper. ... for withTheme HOC, thanks to @brunolemos (See #712); Add innerRef...
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
@denkristoffer That happens because your
InputWithRef
component (which shouldn’t be necessary in the first place 😉) tries to use theref
prop, which is a special prop and thus not accessible to you. tl;dr you can’t passref
and expect to receive it in the component. That’s why we call itinnerRef
. Renaming it fixes the problem: https://codesandbox.io/s/72m8xxy121Btw it’s not preferable to post comments on closed/stale/old issues (this issue is all of those three things 😅) It’s easier to create a new issue or ask for help on Spectrum
This PR should fix this 😄 https://github.com/styled-components/styled-components/pull/710
@evan-scott-zocdoc @mxstbr