You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A breaking change in lifecycle behavior has been observed in versions 0.83.4 and 0.84.1.
On iOS, when a user force-quits (kills) the app, React components normally do not trigger their unmount lifecycles (componentWillUnmount or useEffect cleanup) because the JS engine is terminated abruptly.
However, in these specific versions, if the keyboard was currently open or had been opened and then closed during the session, the unmount lifecycle is triggered upon the app being killed. If the keyboard was never opened during the app's session, the unmount lifecycle is not triggered (matching traditional behavior).
This inconsistency causes side effects, such as unexpected API calls or local storage wipes, to run during a process termination where they previously did not.
This behavior doesn't happen on Android and creates inconsistency between platforms.
Steps to reproduce
Since app is killed debugger is detached. AsyncStorage is used to save timestamp of unmount called
Open the application.
Observe a component that logs to the console useEffect and class component unmount timestamp
Scenario A (No Keyboard): Kill the app via the iOS App Switcher.
Result: No logs appear on next launch (Expected behavior).
Scenario B (Keyboard Active): Reopen the app, tap a TextInput to bring up the keyboard. Kill the app via the App Switcher.
Result: The unmount logs appear next launch (Inconsistent behavior).
Scenario C (Keyboard Dismissed): Reopen the app, open the keyboard, close the keyboard. Kill the app via the App Switcher.
Result: The unmount logs appear next launch (Inconsistent behavior).
Description
A breaking change in lifecycle behavior has been observed in versions 0.83.4 and 0.84.1.
On iOS, when a user force-quits (kills) the app, React components normally do not trigger their unmount lifecycles (componentWillUnmount or useEffect cleanup) because the JS engine is terminated abruptly.
However, in these specific versions, if the keyboard was currently open or had been opened and then closed during the session, the unmount lifecycle is triggered upon the app being killed. If the keyboard was never opened during the app's session, the unmount lifecycle is not triggered (matching traditional behavior).
This inconsistency causes side effects, such as unexpected API calls or local storage wipes, to run during a process termination where they previously did not.
This behavior doesn't happen on Android and creates inconsistency between platforms.
Steps to reproduce
Since app is killed debugger is detached. AsyncStorage is used to save timestamp of unmount called
Open the application.
Observe a component that logs to the console useEffect and class component unmount timestamp
Scenario A (No Keyboard): Kill the app via the iOS App Switcher.
Result: No logs appear on next launch (Expected behavior).
Scenario B (Keyboard Active): Reopen the app, tap a TextInput to bring up the keyboard. Kill the app via the App Switcher.
Result: The unmount logs appear next launch (Inconsistent behavior).
Scenario C (Keyboard Dismissed): Reopen the app, open the keyboard, close the keyboard. Kill the app via the App Switcher.
Result: The unmount logs appear next launch (Inconsistent behavior).
React Native Version
0.83.4, 0.84.1
Affected Platforms
Runtime - iOS
Output of
npx @react-native-community/cli infoStacktrace or Logs
MANDATORY Reproducer
https://github.com/worksnk/rn_ios_unmount_breaking_change
Screenshots and Videos
Video shows 3 scenarios in described in steps with logs
repducer_video.mov