caspermc
caspermc

Reputation: 492

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)

is there a way to do this?

Upvotes: 2

Views: 477

Answers (1)

Art
Art

Reputation: 461

Yes, simply add children to your destructuring,

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

Upvotes: 3

Related Questions