I recently started using Next.js and Tailwindcss. I want to create a custom component that can be used as follows -
<CustomComponent> Hello World </CustomComponent>
While searching for how to use this, I came across an answer which said -
const CustomComponent = props => {
return (
<>
<div {...props} className="text-red-900" />
</>
)
}
In my example, the CustomComponent will simple make the text-color to a shade of red.
I can now use this component as <CustomComponent> Hello World </CustomComponent>.
What I don't understand is this line - <div {...props} className="text-red-900" />. I couldn't find anything like this in the reactjs docs.
Is this an appropriate way of passing props as HTML attributes? How does it work?