Skip to content

Instantly share code, notes, and snippets.

@xdesro
Created August 17, 2020 18:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdesro/6e9a3ea2f3ea84a2159286ee853c9fc7 to your computer and use it in GitHub Desktop.
Save xdesro/6e9a3ea2f3ea84a2159286ee853c9fc7 to your computer and use it in GitHub Desktop.
Godforsaken margin-top React component.
const MarginTop = (props) => (
<div>
{Array.from(Array(props.spacing)).map((br) => (
<br />
))}
{props.children}
</div>
);
ReactDOM.render(
<MarginTop spacing={5}>
<h1>Lorem ipsum</h1>
<p>Dolor sit amet omg</p>
</MarginTop>,
document.getElementById("root")
);
// Output:
// <div><br><br><br><br><br><h1>Lorem ipsum</h1><p>Dolor sit amet omg</p></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment