I have this code for example:
interface Props {
children: any,
className?: string,
marginTop?: number,
marginBottom?: number,
}
const Div = styled.div`
${(props: Props) => { return css`
flex:1;
${props.marginTop && "margin-top: " + props.marginTop + "px;"};
${props.marginBottom && "margin-bottom: " + props.marginBottom + "px;"};
`;
}}
`;
export const Column: React.FC<Props> = ({ children, className marginTop, marginBottom }) => {
return (
<Div className={className} marginBottom={marginBottom} marginTop={marginTop}>
{children}
</Div>
);
};
Now I have to declare the props twice, once in Props and once in the exported component.
Is there a way to make all defined Props available as props for the component?
Just to make it clear, this is the part I'm trying to save my self to write again:
({ children, className marginTop, marginBottom })