fix(react): add SSR check to IonTabs (#23696)

resolves #23651
This commit is contained in:
William Martin
2021-08-02 10:28:51 -04:00
committed by GitHub
parent caf0917623
commit f2a05bed1e
2 changed files with 7 additions and 2 deletions

View File

@ -3,18 +3,19 @@ import React, { Fragment } from 'react';
import { NavContext } from '../../contexts/NavContext'; import { NavContext } from '../../contexts/NavContext';
import PageManager from '../../routing/PageManager'; import PageManager from '../../routing/PageManager';
import { HTMLElementSSR } from '../../utils/HTMLElementSSR';
import { IonRouterOutlet } from '../IonRouterOutlet'; import { IonRouterOutlet } from '../IonRouterOutlet';
import { IonTabBar } from './IonTabBar'; import { IonTabBar } from './IonTabBar';
import { IonTabsContext, IonTabsContextState } from './IonTabsContext'; import { IonTabsContext, IonTabsContextState } from './IonTabsContext';
class IonTabsElement extends HTMLElement { class IonTabsElement extends HTMLElementSSR {
constructor() { constructor() {
super(); super();
} }
} }
if (window && window.customElements) { if (typeof (window as any) !== 'undefined' && window.customElements) {
const element = customElements.get('ion-tabs'); const element = customElements.get('ion-tabs');
if (!element) { if (!element) {
customElements.define('ion-tabs', IonTabsElement); customElements.define('ion-tabs', IonTabsElement);

View File

@ -0,0 +1,4 @@
export const HTMLElementSSR = (
typeof HTMLElement !== 'undefined'
? HTMLElement
: class {}) as typeof HTMLElement;