forked from ddrilling/asb_cloud_front
16 lines
402 B
TypeScript
16 lines
402 B
TypeScript
|
import { FC, memo } from 'react'
|
||
|
|
||
|
export type BasePluginSettings = {
|
||
|
enabled?: boolean
|
||
|
}
|
||
|
|
||
|
export const wrapPlugin = <S,>(Component: FC<S>, defaultEnabled?: boolean) => {
|
||
|
const wrappedComponent = memo<S & BasePluginSettings>(({ enabled, ...props }) => {
|
||
|
if (!(enabled ?? defaultEnabled)) return <></>
|
||
|
|
||
|
return <Component {...(props as S)} />
|
||
|
})
|
||
|
|
||
|
return wrappedComponent
|
||
|
}
|