Skip to content

Instantly share code, notes, and snippets.

@brudil
Forked from kitze/conditionalwrap.js
Last active April 23, 2018 21:26
Show Gist options
  • Save brudil/405df6907df953c459ccb70062a19d81 to your computer and use it in GitHub Desktop.
Save brudil/405df6907df953c459ccb70062a19d81 to your computer and use it in GitHub Desktop.
one-line React component for conditionally wrapping children
interface IProps {
condition: boolean;
wrap(wrapper: (children: any) => any): any;
children: any;
}
export const ConditionalWrap = ({ condition, wrap, children }: IProps) =>
condition ? wrap(children) : children;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment