mirror of
https://github.com/Mastermindzh/react-cookie-consent.git
synced 2025-04-20 22:13:33 +02:00
19 lines
613 B
TypeScript
19 lines
613 B
TypeScript
import { FunctionComponent, ReactNode } from "react";
|
|
|
|
type Props = {
|
|
condition: boolean;
|
|
wrapper: (_: ReactNode) => any;
|
|
children: ReactNode;
|
|
};
|
|
|
|
/**
|
|
* A function to wrap elements with a "wrapper" on a condition
|
|
* @param {object} wrappingOptions
|
|
* condition == boolean condition, when to wrap
|
|
* wrapper == style to wrap. e.g <div>{children}</div>
|
|
* children == react passes whatever is between tags as children. Don't supply this yourself.
|
|
*/
|
|
export const ConditionalWrapper: FunctionComponent<Props> = ({ condition, wrapper, children }) => {
|
|
return condition ? wrapper(children) : children;
|
|
};
|