import type { FC } from "react"; import { getConditionResult } from "./getConditionResults"; import { render } from "./render"; import type { ComponentWithConditionPropsWithFunctionChildren } from "./types"; import { _memo, _shallowFn } from "./utils"; /** 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 UnlessFn: FC = ({ condition, children }) => { const conditionResult = Boolean(getConditionResult(condition)); return !conditionResult && children ? render({ children }) : null; }; UnlessFn.defaultProps = { children: null }; export const Unless = _memo(UnlessFn, _shallowFn);