Skip to content

Commit

Permalink
fix: Discard persisted state on Android Activity restart
Browse files Browse the repository at this point in the history
PlayStore console reported some crashes related to react-native-screens
that are related to Activity's `onCreate` method

This bug is well documented in the react-native-screens repository and
the recommended action is to discard the Activity's persisted state
when restarted

This is because the JS state (redux stores, in-component state etc) is
not persisted the same way as the Android activity state, so there can
be some inconsistencies between them when the app is restarted

Discarding the state implies that if Android kills the Activity when
app is on background, then on when going back to the app it will behave
like if it was a fresh start

Another impact is for foldable phones in which the app will restart
when splitted into multi-window. But as the app does not support this
mode, then this would not be an issue (at least for now)

Related documentation:
https://github.com/software-mansion/react-native-screens#android

Related issue:
software-mansion/react-native-screens#17
  • Loading branch information
Ldoppea committed Sep 21, 2023
1 parent 4c62073 commit b6fef17
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected String getMainComponentName() {
protected void onCreate(Bundle savedInstanceState) {
boolean isDarkMode = true;
ImmersiveBars.changeBarColors(this, isDarkMode);
super.onCreate(savedInstanceState);
super.onCreate(null);
RNBootSplash.init(R.drawable.bootsplash, MainActivity.this);
}
}

0 comments on commit b6fef17

Please sign in to comment.