Skip to content

Commit

Permalink
feat(conditional container): allow render without children
Browse files Browse the repository at this point in the history
  • Loading branch information
tutods committed Feb 12, 2024
1 parent 59210a6 commit d7c389c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ const ConditionalContainer = <TRender extends RenderElement, TFallback extends R
const { element, props: renderProps } = render;

// If (typeof element === 'string') {
return createElement(element, renderProps, children);
return children
? createElement(element, renderProps, children)
: createElement(element, renderProps);
}

if (!when && fallback) {
const { element: fallbackElement, props: fallbackProps = {} } = fallback;

return createElement(fallbackElement, fallbackProps, children);
return children
? createElement(fallbackElement, fallbackProps, children)
: createElement(fallbackElement, fallbackProps);
}

// When no `fallback` element is specified
Expand Down

0 comments on commit d7c389c

Please sign in to comment.