Skip to main content

ConditionalWrapper

The ConditionalWrapper component can be used to either render a wrapper around children if provided condition resolves as true or render just children otherwise.

import { ConditionalWrapper } from '@archibald/client';

import { ReactNode } from 'react';

function Wrapper(children: ReactNode) {
return <div>{children}</div>;
}

function TestComponent() {
return (
<ConditionalWrapper condition={BOOLEAN} wrapper={WRAPPER}>
CHILDREN
</ConditionalWrapper>
);
}

Props

The ConditionalWrapper component can receive following props:

PropertyTypeDescription
childrenReactNodeContent to render.
conditionbooleanCondition if true it adds the wrapper around otherwise not.
wrapper(children: ReactNode) => ReactNode)Wrapper which will be put around if the condition is true.