Skip to content

Commit

Permalink
feat(portal): ConditionalPortal supports ReactNode children
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Nov 24, 2021
1 parent 74cee51 commit c83d578
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/portal/src/ConditionalPortal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReactElement } from "react";
import type { ReactElement, ReactNode } from "react";

import type { PortalInto } from "./getContainer";
import { Portal } from "./Portal";
Expand Down Expand Up @@ -27,8 +27,10 @@ export interface RenderConditionalPortalProps {
export interface ConditionalPortalProps extends RenderConditionalPortalProps {
/**
* This children to render.
*
* @remarks \@since 4.0.0 Allows `ReactNode` instead of `ReactElement | null`
*/
children: ReactElement | null;
children: ReactNode;
}

/**
Expand All @@ -41,9 +43,9 @@ export function ConditionalPortal({
portalInto,
portalIntoId,
children,
}: ConditionalPortalProps): ReactElement | null {
}: ConditionalPortalProps): ReactElement {
if (!portal && !portalInto && !portalIntoId) {
return children;
return <>{children}</>;
}

return (
Expand Down

0 comments on commit c83d578

Please sign in to comment.