fix PageAction detection by using a static class property

This commit is contained in:
Sebastian Sdorra
2019-08-28 08:07:46 +02:00
parent 5d439e9783
commit e511f723e5
2 changed files with 8 additions and 3 deletions

View File

@@ -44,6 +44,11 @@ class Page extends React.Component<Props> {
); );
} }
isPageAction(node: any) {
return node.displayName === PageActions.displayName
|| (node.type && node.type.displayName === PageActions.displayName);
}
renderPageHeader() { renderPageHeader() {
const { error, title, subtitle, children, classes } = this.props; const { error, title, subtitle, children, classes } = this.props;
@@ -51,7 +56,7 @@ class Page extends React.Component<Props> {
let pageActionsExists = false; let pageActionsExists = false;
React.Children.forEach(children, child => { React.Children.forEach(children, child => {
if (child && !error) { if (child && !error) {
if (child.displayName === PageActions.displayName) { if (this.isPageAction(child)) {
pageActions = ( pageActions = (
<div <div
className={classNames( className={classNames(
@@ -97,7 +102,7 @@ class Page extends React.Component<Props> {
let content = []; let content = [];
React.Children.forEach(children, child => { React.Children.forEach(children, child => {
if (child) { if (child) {
if (child.displayName !== PageActions.displayName) { if (!this.isPageAction(child)) {
content.push(child); content.push(child);
} }
} }

View File

@@ -9,7 +9,7 @@ type Props = {
}; };
export default class PageActions extends React.Component<Props> { export default class PageActions extends React.Component<Props> {
displayName: string = "PageActions"; static displayName = "PageActions";
render() { render() {
return <>{this.renderContent()}</>; return <>{this.renderContent()}</>;