import type { FC } from 'react'; import { getConditionResult } from './getConditionResults'; import { render } from './render'; import type { ComponentWithConditionPropsWithFunctionChildren } from './types'; /** A shorthand for * * ```jsx * * * { ... } * * * ``` * * The same rules apply to the child elements as with using the ` block. * * @param __namedParameters The props to pass down to the `` component, see {@link ComponentWithConditionProps} */ export const When: FC = ({ condition, children = null }) => { const conditionResult = Boolean(getConditionResult(condition)); return conditionResult && children ? render({ children }) : null; };