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:
| Property | Type | Description |
|---|---|---|
| children | ReactNode | Content to render. |
| condition | boolean | Condition if true it adds the wrapper around otherwise not. |
| wrapper | (children: ReactNode) => ReactNode) | Wrapper which will be put around if the condition is true. |