Created
December 1, 2020 16:08
-
-
Save JamesGelok/ae6a87f6b5201d40b0ca6113c9a1a1e8 to your computer and use it in GitHub Desktop.
component for if you wanted to mix things up and select html by string... but still wanted it to look like React
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 { createElement } from "react"; | |
| export function Box({ children, as = "div", ...props }) { | |
| return createElement(as, props, [...children]); | |
| } | |
| /* | |
| // example | |
| import * as React from "react"; | |
| import style from "./App.module.css"; | |
| import { Box } from "./Box"; | |
| export function App() { | |
| return ( | |
| <Box className={style.app}> | |
| <Box as="h1">Hello CodeSanddiv</Box> | |
| <h2>Start editing to see soesme magic happen!</h2> | |
| </Box> | |
| ); | |
| } | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment