Skip to content

Commit

Permalink
chore: allow custom renderer to receive function or react node (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
fortezhuo authored Dec 3, 2020
1 parent 6de9822 commit 26a4c14
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,9 @@ const ModalizeBase = (
);
};

const renderElement = (Element: React.ReactNode): JSX.Element =>
typeof Element === 'function' ? Element() : Element;

const renderComponent = (
component: React.ReactNode,
name: 'header' | 'footer' | 'floating',
Expand All @@ -680,8 +683,6 @@ const ModalizeBase = (
return null;
}

const renderElement = (Element: React.ReactNode): JSX.Element =>
typeof Element === 'function' ? Element() : Element;
const tag = renderElement(component);

/**
Expand Down Expand Up @@ -757,7 +758,8 @@ const ModalizeBase = (
}

if (customRenderer) {
return React.cloneElement(customRenderer, { ...opts });
const tag = renderElement(customRenderer);
return React.cloneElement(tag, { ...opts });
}

return (
Expand Down

0 comments on commit 26a4c14

Please sign in to comment.