I know the title is weird but let me explain. I have a component with props:
const MainExperienceComponent = props => (
<div>
....
</div>
);
and then I need to export it using a wrapper function like this:
export default withWrapper(MainExperienceComponent);
The problem is that I want to pass inside the withWrapper
a prop. To be more specific I want this: withWrapper(MainExperienceComponent, prop.id)
so as the withWrapper
has two args. How to do this?
You can wrap your
MainExperienceComponent
within the class you want to use it in (the one that has the props you want to pass) and assign it as an instance variable.Your HOC would then accept two arguments:
This is assuming that the
Container
component has access to the props you want to pass in. If you're passing theid
prop into theMainExperienceComponent
component then the HOC would already have access to it.the caller:
the HOC:
If this was the case, there would be no need for passing two arguments to the HOC so I'm not sure this answers your question. Let me know if I'm misunderstanding.