Could someone tell me, how it is 3 dot spread does? I know it wanna passing a isActive(Boolean) into Component SideNavLink. If it true then it has those props. But, I'm wondering what the code does.
I hope I have a great and clear to describe what I wondering.
<NavLink href={href}>
{(isActive) => (
<SideNavLink
{...(isActive && { // this spread operator
bg: "teal.200",
rounded: "sm",
})}
{...props}
/>
)}
</NavLink>
The ... spreads the next spreadable item. In your case if you evaluate the isActive to true you will find,
...{bg: "teal.200", rounded: "sm",}
So the spread operator spread this {bg: "teal.200", rounded: "sm",}
object and returns bg: "teal.200", rounded: "sm"
so that they can be passed as props.