Skip to content

bug: react, tabs accesses values that are not defined in ssr environment #23651

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

Closed
4 of 6 tasks
felquis opened this issue Jul 16, 2021 · 6 comments · Fixed by #23696
Closed
4 of 6 tasks

bug: react, tabs accesses values that are not defined in ssr environment #23651

felquis opened this issue Jul 16, 2021 · 6 comments · Fixed by #23696
Labels
package: react @ionic/react package type: bug a confirmed bug report
Milestone

Comments

@felquis
Copy link

felquis commented Jul 16, 2021

Prequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

ReferenceError: HTMLElement is not defined
    at Object.<anonymous> (/Users/ofelquis/projects/folder-name/node_modules/@ionic/react/dist/index.js:1043:30)

Expected Behavior

  • Smooth integration out of the box with SSR support

  • Documentation should mention SSR on every framework guide page, even though it's still work in progress

Steps to Reproduce

As mentioned at https://nextjs.org/docs/getting-started

1 - start nextjs project - Run:

yarn create next-app folder-name --typescript
cd folder-name

As mentioned at https://ionicframework.com/docs/intro/cdn#ionic-react

2 - install ionic deps - Run:

yarn add @ionic/react

Open pages/_app.tsx and add styles as mentioned at https://ionicframework.com/docs/intro/cdn#css

3 - use a component

Open pages/index.tsx and import

import { IonInput } from '@ionic/react'

And use it inside the jsx return

<IonInput placeholder="Type anything" />

4 - try to start development - run

yarn dev

5 - open the browser preview

ReferenceError: HTMLElement is not defined
    at Object.<anonymous> (/Users/ofelquis/projects/folder-name/node_modules/@ionic/react/dist/index.js:1043:30)

Code Reproduction URL

https://github.com/felquis/ionic-react-issue-report

Ionic Info

[WARN] You are not in an Ionic project directory. Project context may be
missing.

Ionic:

Ionic CLI : 6.16.3

Utility:

cordova-res : not installed globally
native-run : not installed globally

System:

NodeJS : v16.3.0
npm : 7.15.1
OS : macOS Catalina

Additional Information

This project is not with cordova, nor ionic itself, I just want to use a few components from ionic in the react way in an already existing project made with nextjs for instance.

Issues I've found that does not mention the error I report here specifically.

mentions nextjs

does not mention nextjs even though the problem is relared to ssr

Offer Solution but not using the module @ionic/react

Does not use @ionic/react at all

@ionitron-bot ionitron-bot bot added the triage label Jul 16, 2021
@felquis
Copy link
Author

felquis commented Jul 18, 2021

Current work around: next/dynamic with no ssr https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr

@liamdebeasi
Copy link
Contributor

Thanks for the issue. Can you try the following dev build and let me know if it resolves the issue?

npm install @ionic/react@5.7.0-dev.202107192155.86ece8f

@liamdebeasi liamdebeasi changed the title bug: usage with nextjs out of the box bug: react, tabs accesses values that are not defined in ssr environment Jul 19, 2021
@liamdebeasi liamdebeasi added package: react @ionic/react package type: bug a confirmed bug report labels Jul 19, 2021
felquis added a commit to felquis/ionic-react-issue-report that referenced this issue Jul 20, 2021

Verified

This commit was signed with the committer’s verified signature.
JamesNK James Newton-King
@felquis
Copy link
Author

felquis commented Jul 20, 2021

It did solve the issue in the reproduction repo.

@liamdebeasi liamdebeasi added this to the 5.6.13 milestone Jul 21, 2021
@felquis
Copy link
Author

felquis commented Jul 31, 2021

Since after this issue, I've been using Ionic and found an unpredictable behaviour - I commented it out here #22718 (comment) could you triage if I should create a new issue for that case? Thank you.

willmartian added a commit that referenced this issue Aug 2, 2021

Verified

This commit was signed with the committer’s verified signature.
JamesNK James Newton-King
resolves #23651
@liamdebeasi
Copy link
Contributor

Thanks for the issue. This has been resolved via #23696, and a fix will be available in an upcoming release of Ionic Framework.

For #22718 (comment), let's keep discussion in that thread since it seems to be related to the original post.

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 1, 2021

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: react @ionic/react package type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants