Replies: 1 comment 2 replies
-
It's unclear precisely what you're after, as I think this is a bit of an X/Y problem, but you might be missing that function SomeComponent() {
return (
<div>
<WrapperComponent>
{(someProps) => <SomeOtherComponent someProps={someProps} />}
</WrapperComponent>
</div>
);
}
function WrapperComponent(props) {
const somePassedInProp = 'foo';
return (
<section>
{props.children(somePassedInProp)}
</section>
);
} Generally (p)react falls into "Composition over inheritance" so when you're looking for "extending" a component you won't find a whole heck of a lot. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello there!
I have a component modal (a component that needs a reference to perform dom stuff)
That modal receives a form component (a component that will update their children)
These components are held by a HOC page component that handles the overall state
in the page
I tried to do but still doesn't work:
I want to be allow to do this:
So composed.WiredModal inherits or has specific embedded behaviors that abstract the developer to interact with the modal primitives. I know this is usually achieved with contexts but I wanted to be cool.
working alternative ugly as fuck but it does the job since WiredModal is used as a js plain function so there is no jsx rendering
I'll be using defaultProps so every controller overrides it but this is also inconvenient and has limitations for every modal in the page.
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions