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 18, page hides on hot reload

See original GitHub issue

Prerequisites

Ionic Framework Version

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

Current Behavior

The page works fine but when you save a file and the react server reloads part of the UI the react router outlet (IonRouterOutlet) goes blank.

Expected Behavior

The UI to be updated and not blank

Steps to Reproduce

I put together this code sandbox.

Simply change say hello to hello! and save the file, the page goes blank and you see UNMOUNTED in the console but no MOUNTED

This also happens locally with the CRA dev server.

https://codesandbox.io/s/ionic-router-issue-test-ovee4z?file=/src/app.tsx

i.e. this is the state after a save:

image

You then have to physically refresh the browser page to get the UI to work again.

Code Reproduction URL

https://codesandbox.io/s/ionic-router-issue-test-ovee4z?file=/src/app.tsx

Ionic Info

Can’t do this on a sandbox, but locally with the same issue:

➜  broadway git:(main) ✗ ionic info
[WARN] Error loading @capacitor/android package.json: Error: Cannot find module '@capacitor/android/package'

       Require stack:
       - /Users/philjones/.config/yarn/global/node_modules/@ionic/cli/lib/project/index.js
       - /Users/philjones/.config/yarn/global/node_modules/@ionic/cli/lib/index.js
       - /Users/philjones/.config/yarn/global/node_modules/@ionic/cli/index.js
       - /Users/philjones/.config/yarn/global/node_modules/@ionic/cli/bin/ionic

Ionic:

   Ionic CLI       : 6.18.1 (/Users/philjones/.config/yarn/global/node_modules/@ionic/cli)
   Ionic Framework : @ionic/react 6.1.10

Capacitor:

   Capacitor CLI      : 3.6.0
   @capacitor/android : not installed
   @capacitor/core    : 3.6.0
   @capacitor/ios     : 3.6.0

Utility:

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

System:

   NodeJS : v16.14.2 (/usr/local/Cellar/node@16/16.14.2/bin/node)
   npm    : 8.5.0
   OS     : macOS Big Sur

Additional Information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sean-perkinscommented, Jul 6, 2022

I’ve been able to narrow the responsible code to here: https://github.com/ionic-team/ionic-framework/blob/main/packages/react-router/src/ReactRouter/StackManager.tsx#L59-L62

When the outlet is cleared, this arbitrary timeout runs: https://github.com/ionic-team/ionic-framework/blob/main/packages/react/src/routing/ViewStacks.ts#L24-L30

With the behavior for how React tries to resume, the component will re-mount, and the timeout will finally run to clear the page contents.

0reactions
ionitron-bot[bot]commented, Sep 2, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hot Reload Fails, DOM adds an additional iframe
Hot reload continues to work, but the page becomes unresponsive. Can't click or do anything unless you do a manual refresh.
Read more >
Hot Reload is not working in my React App - Stack Overflow
js in src folder. Then Hot reload is not working. I have go to chrome and manually refreshing the page for see changes....
Read more >
React v18.0 – React Blog
In this post, we'll give an overview of what's new in React 18, ... When we design APIs, we try to hide implementation...
Read more >
react-hot-loader - npm
Start using react-hot-loader in your project by running `npm i react-hot-loader`. There are 2700 other projects in the npm registry using ...
Read more >
React-Hot-Loader 4.6. ⚛️ — Hooks, Errors and ... - Medium
React -Hot-Loader was always about hacking into React, and hiding real updates from it by “presenting” proxy components to it, instead of the...
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