Skip to content

Instantly share code, notes, and snippets.

@alexaivars
Created October 15, 2020 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexaivars/2a0f6426252c5c7b37fa411a4f4cfbbe to your computer and use it in GitHub Desktop.
Save alexaivars/2a0f6426252c5c7b37fa411a4f4cfbbe to your computer and use it in GitHub Desktop.
import React from 'react';
import styled, { StyledComponentBase } from 'styled-components';
type ComponentProps = { text: string } & React.HTMLAttributes<HTMLDivElement>;
const Component: React.FunctionComponent<ComponentProps> = ({
text = 'default',
className,
...props
}) => (
<div className={className} {...props}>
{text}
</div>
);
type ComponentWithStyleProps = {
color: string;
} & ComponentProps;
type ComponentWithStyleType = StyledComponentBase<
React.FunctionComponent<ComponentProps>,
any,
ComponentWithStyleProps,
never
>;
export const ComponentWithStyle:ComponentWithStyleType = styled(Component)<
ComponentWithStyleProps
>`
border: 10px solid ${({ color }) => color};
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment