Last active
October 6, 2017 16:31
-
-
Save joakin/e2fe894e5d1b6653ac9d52d43d874b89 to your computer and use it in GitHub Desktop.
Dynamic component type with JSX
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
export default function HeaderLevel({ | |
level, | |
children, | |
...props | |
}: { level: number } & ChildrenProps & ClassProps): JSX.Element { | |
const classes = classOf("HeaderLevel", props.class); | |
const Header = level > 0 && level <= 6 ? `h${level}` : 'div' | |
return <Header class={classes}>{children}</Header>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment