Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to pass props to Elements from Blocks without explicitly passing them #69

Open
umerjaved178 opened this issue Apr 5, 2022 · 1 comment

Comments

@umerjaved178
Copy link

umerjaved178 commented Apr 5, 2022

I am using react with the following functional approach

`
const Divider: React.FunctionComponent = ({children}) => (

// I want to use color props here of Card divider {children}
);

const Card: React.FunctionComponent = ({children, color}) => {
const color = props.color

return(

card {children}
)}

Card.Divider = Divider;
`

and I call these components as following

<Card color="red"> <Card.Divider> Any text <Card.Divider/> <Card />

The problem is: How can I get the color props in the Divider component

PS: I don't want to repeat props passing again for divider like following
<Card color="red"> <Card.Divider color="red"> Any text <Card.Divider/> <Card />
What I want is the following approach and can still able to use color props in Divider component, how can I do that

<Card color="red"> <Card.Divider> Any text <Card.Divider/> <Card />

@umerjaved178
Copy link
Author

Github is having some errors whole displaying a block of code, you can see the issue here
https://stackoverflow.com/questions/71758307/how-can-i-pass-props-to-inner-react-component-using-functional-approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant