(Android) App component reconstructed on split screen resize
See original GitHub issueReact Native version:
React Native Environment Info:
System:
OS: macOS 10.14.5
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Memory: 405.22 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.14.1 - /usr/local/bin/node
npm: 6.7.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 23, 24, 25, 26, 27, 28
Build Tools: 26.0.2, 28.0.3, 29.0.0
System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.5 => 0.59.5
npmGlobalPackages:
react-native-cli: 2.0.1
Steps To Reproduce
- Create a new project via
react-native init AppName
- Add constructor with a
console.log
in the default app component (inApp.js
) - Run the app
Expected behaviour
Switch to split-screen view or pop up view and resize the app window and continue to be able to use the app where it left off.
Actual behaviour
When switching to split screen or pop up view the app component is discarded and reconstructed, meaning the state of the app completely reset. The same thing happens when the app window is resized in this state.
I placed console.log
at the top of both index.js
and App.js
(outside of any class or function) and inside the constructor the the default app class. The logs that were placed at the top of the two files were only called when the app was started while the one in the App constructor was called every time the app window was resized and the state was lost.
This tells me that the JS environment survives, but RN just reinitializes the app for whatever reason.
It seems to be the same as this issue that went stale and was never resolved.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:5
This is a note from android developer:
You should add “screenLayout|smallestScreenSize” into “android:configChanges” to make it works
This worked for me actually! I’m surprised I couldn’t find this listed anywhere. It should almost be included be default when the android project is generated.