Created
February 26, 2018 08:36
-
-
Save fanyang89/27fd8c344e03c810b80d4d30a3c021d6 to your computer and use it in GitHub Desktop.
Provide props to styled elements in Typescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as React from "react"; | |
| import { ThemedStyledFunction } from "styled-components"; | |
| const themed = <IComponentProps, U extends HTMLElement = HTMLElement>( | |
| styled: ThemedStyledFunction<any, any>, | |
| ): ThemedStyledFunction<IComponentProps & React.HTMLProps<U>, any> => styled; | |
| export default themed; | |
| // eg. | |
| // import styled, { StyledComponentClass } from "styled-components"; | |
| // import themed from "../themed"; | |
| // const Foo = themed<IFooProps>(styled.div)` | |
| // width: 100%; | |
| // `; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment