Skip to content

Commit 8302a46

Browse files
committed
Accept null elements in Flex
1 parent 1cb1d62 commit 8302a46

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/lib/components/layout/Flex.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export type FlexProps = PositionProps &
2929
borderColor?: 'light' | 'dark';
3030
};
3131

32-
type ButtonChild = ReactElement<ButtonProps>;
32+
type ButtonChild = ReactElement<ButtonProps> | null;
3333

3434
type PositionProps = Required<Pick<ButtonProps, 'top' | 'left'>>;
3535

@@ -271,8 +271,8 @@ export const Flex = forwardRef(function FlexWithRef(
271271
);
272272
});
273273

274-
const isValidChild = (child: ReactElement) =>
275-
child.type === Button || child.type === Flex;
274+
const isValidChild = (child: ReactElement | null): child is ReactElement =>
275+
child !== null && (child.type === Button || child.type === Flex);
276276

277277
const directionMap: Record<
278278
NonNullable<FlexProps['direction']>,

0 commit comments

Comments
 (0)