fix(react): setupIonicReact no longer crashes in SSR environment (#24604)

This commit is contained in:
Liam DeBeasi
2022-01-19 15:48:46 -05:00
committed by GitHub
parent 35e5235645
commit 360643d96a
2 changed files with 19 additions and 18 deletions

View File

@ -197,7 +197,9 @@ export const setupIonicReact = (config: IonicConfig = {}) => {
* TODO: Remove when all integrations have been * TODO: Remove when all integrations have been
* migrated to CE build. * migrated to CE build.
*/ */
document.documentElement.classList.add('ion-ce'); if (typeof (document as any) !== 'undefined') {
document.documentElement.classList.add('ion-ce');
}
initialize({ initialize({
...config ...config

View File

@ -21,24 +21,23 @@ const getHelperFunctions = () => {
export const IonicVue: Plugin = { export const IonicVue: Plugin = {
async install(_: App, config: IonicConfig = {}) { async install(_: App, config: IonicConfig = {}) {
if (typeof (window as any) !== 'undefined') { /**
* By default Ionic Framework hides elements that
/** * are not hydrated, but in the CE build there is no
* By default Ionic Framework hides elements that * hydration.
* are not hydrated, but in the CE build there is no * TODO: Remove when all integrations have been
* hydration. * migrated to CE build.
* TODO: Remove when all integrations have been */
* migrated to CE build. if (typeof (document as any) !== 'undefined') {
*/
document.documentElement.classList.add('ion-ce'); document.documentElement.classList.add('ion-ce');
const { ael, rel, ce } = getHelperFunctions();
initialize({
...config,
_ael: ael,
_rel: rel,
_ce: ce
});
} }
const { ael, rel, ce } = getHelperFunctions();
initialize({
...config,
_ael: ael,
_rel: rel,
_ce: ce
});
} }
}; };