Skip to content

Commit

Permalink
fix(react): setupIonicReact no longer crashes in SSR environment (#24604
Browse files Browse the repository at this point in the history
)
  • Loading branch information
liamdebeasi committed Jan 19, 2022
1 parent 35e5235 commit 360643d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
4 changes: 3 additions & 1 deletion packages/react/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ export const setupIonicReact = (config: IonicConfig = {}) => {
* TODO: Remove when all integrations have been
* migrated to CE build.
*/
document.documentElement.classList.add('ion-ce');
if (typeof (document as any) !== 'undefined') {
document.documentElement.classList.add('ion-ce');
}

initialize({
...config
Expand Down
33 changes: 16 additions & 17 deletions packages/vue/src/ionic-vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@ const getHelperFunctions = () => {
export const IonicVue: Plugin = {

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
* hydration.
* TODO: Remove when all integrations have been
* migrated to CE build.
*/
/**
* By default Ionic Framework hides elements that
* are not hydrated, but in the CE build there is no
* hydration.
* TODO: Remove when all integrations have been
* migrated to CE build.
*/
if (typeof (document as any) !== 'undefined') {
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
});
}
};

0 comments on commit 360643d

Please sign in to comment.