After setting up my react project using the typescript template, I decided to style the material-ui Button component using the 'styled' method from the styled-components library as shown below:
import React from 'react';
import styled from 'styled-components';
import Button, {ButtonProps} from "@material-ui/core/Button";
type StyledButtonProps = ButtonProps & { primary?: boolean }
const styledButton = styled(Button)`
background-color: ${(props: StyledButtonProps) => props.primary ? "palevioletred" : "white"};
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
padding: 7px 14px;
&:hover {
background-color: aqua;
}
& .MuiButton-label {
color: #070303;
}
` as React.ComponentType<StyledButtonProps>
export default styledButton;
Everything seemed to be working fine until I tried to use this Styled button with a boolean value for primary. However, an unexpected warning message appeared when I attempted to implement it like so:
<StyledButton primary={true}>Styled Buton</StyledButton>
The warning message that popped up can be viewed here.
I'm puzzled as to why this warning is occurring. Any suggestions on how to resolve it?