'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?
Solution 1:[1]
Yes, simply add children to your destructuring,
const Button = ({children, href, className, rippleColor, type}) => {
...
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Art |
