Access wrapped component
See original GitHub issueHi, is it possible to access wrapped component such as:
const Universal = universal(() => import('MyComponent'))
// after some time, I need to do some actions based on static properties of the original component
if (Universal.wrappedComponent && Universal.wrappedComponent.doSomething) {
// do something
}
// I cannot rely on hoisting, because the imported component may not have that static declared
if (Universal.doSomething) // I can't be sure if the static is missing or if the component has not yet loaded
I know about the callbacks, I was just wondering if there is a shorter way for this… Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
React HOC - Access wrapped component function
Using this approach, you are making your HOC aware of a function present inside the wrapped component, creating a tight coupling between the...
Read more >Higher-Order Components - React
And that's it! The wrapped component receives all the props of the container, along with a new prop, data , which it uses...
Read more >Access wrapped component's methods from a contrainer #267
A simple component may have public methods that are accessible if it's a ref somewhere. I usually use if for focus, scrollToBottom etc....
Read more >How to Wrap One React Component into Another | Pluralsight
In React, higher-order components, or HOCs, are functions that take a component and output ... Wrapped component is the original component.
Read more >Javascript – React HOC – Access wrapped component function
Hi guys, i have react component and want to transform it in some way in my HOC component. ... Is this even possible...
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
I’m currently working on some much desired Webpack 4 upgrades for the universal family. After that’s done, I can try and look into this, if you have the drive to lay the groundwork on the refs related stuff- we can try to collaborate on it.
There’s a lot happening with Some big upgrades that we are gonna release, time constraints are hard to manage 😋
@EdonGashi That helps, but
react-universal-component
itself would need to (and should) implement theforwardRef
API to pass along refs to components it wraps. There’s never any need to access the universal component itself via aref
assignment.