I have a simple button component, I am styling it with styled components, but I can not send a simple prop to the component as TypeScript complains with No overload matches this call
App.tsx
import React from 'react';
import Button from '../form/button';
export const App = (): React.ReactElement => <Button secondary>Click me</Button>;
Button.tsx
import React from 'react';
import styled from 'styled-components';
const StyledButton = styled.button`
background-color: #333;
padding: 10px 20px;
color: ${({ secondary }) => (secondary ? 'white' : 'red')};
`;
interface Props {
children: string;
secondary?: any;
}
const Button: React.FC<Props> = ({ children, secondary }) => (
<StyledButton secondary={secondary}>{children}</StyledButton>
);
export default Button;
This should work, what does TypeScript needs me to specify? The error is not very helpful
No overload matches this callchildren: React.ReactNodeandsecondary: booleanNo overload matches this call