File size: 322 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { cloneElement } from 'react'

// type ConditionalWrapperProps = {
//     children: ReactNode
//     condition: boolean
//     wrapper: ReactElement
// }

export const ConditionalWrapper = ({ children, condition, wrapper }) => {
    if (!condition) return children

    return cloneElement(wrapper, {}, children)
}