question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
felquiscommented, Jul 20, 2021

It did solve the issue in the reproduction repo.

1reaction
liamdebeasicommented, Jul 19, 2021

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
Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: react, tabs accesses values that are not defined in ssr ...
Prequisites I have read the Contributing Guidelines. I agree to follow the Code of Conduct. I have searched for existing issues that already ......
Read more >
React tabs with undefined property - Stack Overflow
1 Answer 1 ... You get the error because PropTypes is no longer part of the React package. React.PropTypes gives you undefined ,...
Read more >
WebBrowser - Expo Documentation
WebBrowser. expo-web-browser provides access to the system's web browser and supports handling redirects. On iOS, it uses SFSafariViewController or ...
Read more >
Portals - React
Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component. ReactDOM.createPortal(child, ......
Read more >
referenceerror: navigator is not defined react - You.com
Probably this package is not suitable for SSR. It seems like it calls navigator without checking availability of the browser api and it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found