Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Access children in function component without the props parameter

i’ve created a class that looks like this:

const Button = ({href, className, rippleColor, type}) => {
... 
}

i’m using the component like this:

<Button rippleColor={'#ff0000'} type={'primary'} className={'my-4'}>Test</Button>

now i want to get access to the props.children of the component without switching ({href, className, rippleColor, type}) to (props)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

is there a way to do this?

>Solution :

Yes, simply add children to your destructuring,

const Button = ({children, href, className, rippleColor, type}) => {
... 
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading