File size: 552 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
// @flow
// Conditionally wrap a Component in some more JSX
//
// Usage:
// <ConditionalWrap
// condition={shouldLink}
// wrap={children => <TouchableOpacity onPress={this.onPress}>{children}</TouchableOpacity>}
// >
// <OtherComponent />
// </ConditionalWrap>
import type { Node } from 'react';
type Props = {
condition: boolean,
wrap: (children: Node) => *,
children: Node,
};
function ConditionalWrap({ condition, wrap, children }: Props) {
return condition ? wrap(children) : children;
}
export default ConditionalWrap;
|