Skip to content

Commit

Permalink
apply ternary
Browse files Browse the repository at this point in the history
  • Loading branch information
rshen91 committed Sep 8, 2022
1 parent 6910e41 commit 0556d16
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions packages/shared-ux/router/impl/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,16 @@ export const Route = ({ children, component: Component, render, ...rest }: Route
if (component) {
return <ReactRouterRoute {...rest} component={component} />;
}
if (render) {
if (render || typeof children === 'function') {
const renderFunction = typeof children === 'function' ? children : render;
return (
<ReactRouterRoute
{...rest}
render={(props) => (
<>
<MatchPropagator />
{render(props)}
</>
)}
/>
);
}
if (typeof children === 'function') {
return (
<ReactRouterRoute
{...rest}
render={(props) => (
<>
<MatchPropagator />
{children(props)}
{/* @ts-ignore else condition exists if renderFunction is undefined*/}
{renderFunction(props)}
</>
)}
/>
Expand Down

0 comments on commit 0556d16

Please sign in to comment.