Skip to content

Instantly share code, notes, and snippets.

@JamesGelok
Created December 1, 2020 16:08
Show Gist options
  • Select an option

  • Save JamesGelok/ae6a87f6b5201d40b0ca6113c9a1a1e8 to your computer and use it in GitHub Desktop.

Select an option

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
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