Pass And Amend Element Props With A React Function

August - 2021

This is with a spread and destructuring

function Box({className, ...rest}) {
    return <div className={`box ${className}`} {...rest} />
}
const element = (
    <Box className="blue" style={{fontStyle: 'italic'}}>
        This is the box
    </Box>
)

results in:

<div class="box blue" style="italic">
    This is the box
</div>