I have a styled component that looks like this:
export const TestClassButton = styled(Button)({ ... })
And I use it like this:
<Tooltip arrow title={"status"}>
<TestClassButton
id={"button-status-dialog"}
onClick={() => setShowDialog(!showDialog)}
>
<ListAltIcon />
</TestClassButton>
</Tooltip>
Result:
If I try to style a little bit more my styled component like this:
export const TestClassButton = styled((props) => (
<Button variant={"outlined"} {...props} />
))({ ... });
Then the component where I use it says this:
And the Tooltip stops working. Any idea why is this happening? Isn't this the propper way to use styled components?
My soultion to avoid extra typos and errors was to separate the Material UI properties from the styled component like this:
const StyledButton = ({ children, ...props }) => (
<Button size={"small"} variant={"contained"} {...props}>
{children}
</Button>
);
export const TestClassButton = styled(StyledButton)({ ... });