Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
});
}
};