I need some ideas for a folder structure/mental model in React.
I have an Item
component. It stays the same.
It can be wrapped in either a Link
with a URL prop or a Button
with an onClick prop.
My current folder structure solution looks like this:
-Item
-wrapperComponents
-Link
-Button
Both the Link and Button components wrap around the children prop. Much like this:
react stuff ...
return(
<button onClick={props.handleOnClick}>
{props.children}
</button>
)
And this is how I call them:
<Button>
<Item />
</Button>
or
<Link>
<Item />
</Link>
I am looking for a better, more elegant solution.
I've tried sending the wrapper components to the Item
but React doesn't allow to use them as a wrapper that would take children.