-
Notifications
You must be signed in to change notification settings - Fork 0
Conditional Wrap
Matt Layton edited this page Apr 13, 2020
·
2 revisions
ConditionalWrap is an abstraction which makes it simple to conditionally wrap content, whilst avoiding a duplicated definition of the content.
In this scenario the content would be wrapped inside a modal, but only for mobile devices.
<ConditionalWrap
condition={isMobile}
wrap={children => <Modal>{children}</Modal>}
children={
<p>Content here!</p>
}
/>| Prop | PropType | Description |
|---|---|---|
| condition | Bool! | The condition to pass for children to be wrapped |
| wrap | Fn! | Render prop with children as the only argument. Invoked when the condition is true |