Skip to content

Instantly share code, notes, and snippets.

View g-delmo's full-sized avatar
🚀
Focusing

Guillermo del Molino g-delmo

🚀
Focusing
View GitHub Profile
@kitze
kitze / conditionalwrap.js
Created October 25, 2017 16:54
one-line React component for conditionally wrapping children
import React from 'react';
const ConditionalWrap = ({condition, wrap, children}) => condition ? wrap(children) : children;
const Header = ({shouldLinkToHome}) => (
<div>
<ConditionalWrap
condition={shouldLinkToHome}
wrap={children => <a href="/">{children}</a>}
>