-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
bug: hardware back button not firing in react development build #26599
Comments
Thanks for the report. I'm not able to reproduce this behavior when testing on a Pixel 4a with Android 13. Does this issue persist on a physical Android device? |
@liamdebeasi I can reproduce this on a physical device as well yes -- but only when using a debug build, it works as expected when running a release build. I'll update the issue to reflect this, but are you sure you're on the |
Running in debug mode does reproduce the issue. The
false which causes the page to not go back. It appears there are mounting/unmounting differences when running in debug vs. production mode. I am going to take a closer look at this.
|
In development mode, React creates multiple instances of Both instances register an |
Here is a dev build if you are interested in testing the proposed fix:
|
Thanks for the issue. This has been resolved via #26614, and a fix will be available in an upcoming release of Ionic Framework. Feel free to continue testing the dev build, and let me know if you run into any issues. |
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. |
Prerequisites
Ionic Framework Version
Current Behavior
When using React 18's
createRoot
API and@ionic/react-router
(which is the default created with Ionic's CLI when doingionic start photo-gallery tabs --type=react --capacitor
for example) with a debug build, the hardware back button on Android does not work at all.Default tabs app when using
createRoot
APIdoesnt-work.mp4
Default tabs app when using deprecated
ReactDOM.render
works.mp4
When you change back to using the old

ReactDOM.render
API, it works again. However this is discouraged and no longer supported by React itself (see https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-client-rendering-apis):Expected Behavior
Hardware back button works when using React 18's
createRoot
API just as it does when using the deprecatedReactDOM.render
API on both debug and release builds.Steps to Reproduce
In the attached reproduction URL you'll find two branches -- a
main
branch which shows the issue (which is the default starter app created by runningionic start app-name tabs --type=react --capacitor
), and aworks
branch which is the same app but changed to use the oldReactDOM.render
API instead of thecreateRoot
API, which works as expected.Run the app by checking out the branch you want and then:
npm i
ionic cap run android -l --external
and selecting an emulator / real-deviceCode Reproduction URL
https://github.com/tallpants/ionic-react-18-router-reproduction
Ionic Info
Additional Information
No response
The text was updated successfully, but these errors were encountered: