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.

Access wrapped component

See original GitHub issue

Hi, 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:closed
  • Created 5 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ScriptedAlchemycommented, May 30, 2018

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 😋

1reaction
matthew-deancommented, May 23, 2018

@EdonGashi That helps, but react-universal-component itself would need to (and should) implement the forwardRef API to pass along refs to components it wraps. There’s never any need to access the universal component itself via a ref assignment.

Read more comments on GitHub >

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

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