-
-
Save brudil/405df6907df953c459ccb70062a19d81 to your computer and use it in GitHub Desktop.
one-line React component for conditionally wrapping children
This file contains 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
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