asb_cloud_front/src/components/d3/plugins/base.tsx

16 lines
402 B
TypeScript
Raw Normal View History

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
}