Created
May 21, 2022 10:07
-
-
Save Asjas/f727953063f713f2cd06c7b29c3d4af4 to your computer and use it in GitHub Desktop.
React "as" Prop Example
This file contains 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
const Headline = ({ as = 'h1', children }) => { | |
const As = as; | |
return <As>{children}</As>; | |
}; | |
const App = () => { | |
return ( | |
<> | |
<Headline>Hello React</Headline> | |
<Headline as="h2">Hello React</Headline> | |
</> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment