Skip to content

Instantly share code, notes, and snippets.

@Asjas
Created May 21, 2022 10:07
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 Asjas/f727953063f713f2cd06c7b29c3d4af4 to your computer and use it in GitHub Desktop.
Save Asjas/f727953063f713f2cd06c7b29c3d4af4 to your computer and use it in GitHub Desktop.
React "as" Prop Example
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