I seem to be having troubles spreading the props in a component that uses StyledComponents under the hood. Whenever I try to pass a prop not defined in the interface (a style tag, for instance), I get an error. Here´s my current implementation:
interface IParagraphProps {
text: string;
}
const StyledParagraph = styled.p`
max-width: 90%;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
`;
const Paragraph = (props: IParagraphProps) => {
const { text, ...rest } = props;
return (
<StyledParagraph {...rest}>{text}</StyledParagraph>
)
};
export default Paragraph;
EDIT: Here´s the error: Property 'style' does not exist on type 'IntrinsicAttributes & IParagraphProps'.
And the place where I use this component:
const Card = () => {
return (
<Paragraph
style={{ marginTop: "1rem" }}
text="whatever"
/>)
};