Skip to content
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

[2.3.0-beta.1] React-Navigation Back Button unmounts previous screen with Reanimated #2460

Closed
1 of 3 tasks
SultanTanirkul opened this issue Sep 27, 2021 · 25 comments · Fixed by #2617
Closed
1 of 3 tasks
Assignees
Labels
Area: Layout Animations Bug Important This seem to be a serious issue and we will need to take a deeper look into it some time soon Library: Screens 🏠 Reanimated 2

Comments

@SultanTanirkul
Copy link

SultanTanirkul commented Sep 27, 2021

Description

After updating reanimated to the latest version 2.3.0.-beta.1 from 2.2.2 the navigation between existing screens removes interactivity as well as some styles from the screen (presumably unmounts previous screen when back button is pressed). Simple example is navigating from screen 'A' to 'B' and going back causes this bug or issue. It is only seems to affect native stack navigator.

Everything is working just fine on version 2.2.2

Expected behavior

Navigation from one screen to another and then using back button shows the previous screen as it has been before navigating.

Actual behavior & steps to reproduce

Navigation from one screen to another and then using back button unmounts the previous screen.

Snack or minimal code example

https://github.com/SultanTanirkul/navigation-reanimated-bug

Package versions

  • React Native: 0.65.1
  • React Native Reanimated: 2.3.0-beta.1
  • @react-navigation/native: 6.0.4
  • @react-navigation/native-stack: 6.2.2
  • react-native-screens": 3.7.2

Affected platforms

  • Android
  • iOS
  • Web
@github-actions
Copy link

Issue validator

The issue is valid!

@exneval
Copy link

exneval commented Sep 27, 2021

I'm also able to reproduce the issue in 2.3.0-beta.1 with @react-navigation/native-stack 6.2.2 and react-native-screens 3.7.2

@mateusz1913
Copy link
Contributor

I am also able to reproduce similar issue, you can check example repo https://github.com/mateusz1913/react-native-avoid-softinput/tree/master/example

Package versions

  • @react-navigation/native: "6.0.3",
  • @react-navigation/native-stack: "6.2.0",
  • react: "17.0.2",
  • react-native: "0.65.1",
  • react-native-reanimated: "^2.3.0-beta.1",
  • react-native-safe-area-context: "3.3.2",
  • react-native-screens: "3.7.2"

When screen is dismissed (via back button or hardware back press), it is pushed again on screen, which makes app not responding to any user's input.

here is gif of incorrect behavior
bug

@evgenusov
Copy link

Same for me!

@Ralisson-Mattias
Copy link

Same problem here

@nazrdogan
Copy link

Same for me

@Darapsas
Copy link

Darapsas commented Sep 30, 2021

Same here, with these package versions:

  "dependencies": {
    "@react-native-masked-view/masked-view": "0.2.6",
    "@react-navigation/bottom-tabs": "6.0.7",
    "@react-navigation/devtools": "6.0.2",
    "@react-navigation/native": "6.0.4",
    "@react-navigation/stack": "6.0.9",
    
    "react": "17.0.2",
    "react-native": "0.65.1",
    
    "react-native-gesture-handler": "1.10.3",
    "react-native-reanimated": "2.3.0-beta.1",
    "react-native-safe-area-context": "3.3.2",
    "react-native-screens": "3.8.0"
  }

The issue only appears in the release version (using hermes engine), the development version seems to work pretty well

@tominou
Copy link

tominou commented Oct 3, 2021

Same issue here.
react-native 0.66.0
react-native-reanimated 2.3.0-beta.2

@yaredtaye
Copy link

I confirm Same issue .
react-native 0.66.0
react-native-reanimated 2.3.0-beta.2

When will the fix be available?

@ruairioliverwv
Copy link

This resolves it for me: #2477 (comment)

@mlecoq
Copy link

mlecoq commented Oct 6, 2021

For information when I set a custom headerLeft :

options={({navigation}) => ({
          headerLeft: () => <Button title="back" onPress={navigation.goBack} />,
        })}

I have this error
The specified child already has a parent. You must call removeView() on the child's parent first

@bilarslan
Copy link

The same for me :(

"react": "17.0.2",
"react-native": "0.66.0",
"react-native-reanimated": "^2.3.0-beta.2",
"@react-navigation/native": "^6.0.4",
"@react-navigation/native-stack": "^6.2.2",

@nazacity
Copy link

same for me

@cyim02
Copy link

cyim02 commented Oct 12, 2021

same for me. needed RN 0.66 for preparing the support on iOS 15 and Android 12.

@savv
Copy link

savv commented Oct 12, 2021

I have the same error, and I can confirm that the AAR here fixes things for me.

@piaskowyk would it make sense to release 2.2.3, with an aar for rn .66?

@hannojg
Copy link
Contributor

hannojg commented Oct 12, 2021

I have the same error, and I can confirm that the AAR here fixes things for me.

@piaskowyk would it make sense to release 2.2.3, with an aar for rn .66?

I mean, this fix works because it uses version < 2.3

We still need a fix for version 2.3 on android 😅

@savv
Copy link

savv commented Oct 12, 2021

I guess many people upgraded to 2.3.0-beta.x only because it supports RN 0.66.0. A new patch release that supports it would unblock all those many people.

@hannojg
Copy link
Contributor

hannojg commented Oct 13, 2021

Just tested whether #2486 has fixed this issue as stated here, but unfortunately, it didn't.

@savv
Copy link

savv commented Oct 13, 2021

I prepared a version of 2.2.2 that is compatible with RN66 here: https://github.com/savv/react-native-reanimated/tree/2.2.6
I also compiled it and pushed it here

You can use it in your react native project like this:
"react-native-reanimated": "npm:react-native-reanimated-savv@2.2.6",

@piaskowyk piaskowyk added the Important This seem to be a serious issue and we will need to take a deeper look into it some time soon label Oct 14, 2021
@bilarslan
Copy link

Just tested with v2.2.3 on android and the issue solved 🎉🎉🎉

@albinekb
Copy link

Thank you for your temporary version @savv! I have updated to 2.2.3 on Android now and the issue is solved 🎉

@hannojg
Copy link
Contributor

hannojg commented Oct 18, 2021

Don't want a wrong impression to arise here: the issue is not solved. The issue is still existing for the beta version of 2.3.0.
Using 2.2.3 is obviously no option if you want to use the new features from 2.3.0 😄
(Haven't tested beta 3 yet, but as far as I can see, none of the PRs that are included in beta 3 have fixed this issue)

@Darapsas
Copy link

The issue seems to still persist on the latest package versions:

"react-native": "0.66.1",
"react-native-reanimated": "2.3.0-beta.3",

@000xuandu
Copy link

000xuandu commented Nov 9, 2021

Same issue:

"react-native": "0.64.0",
"react-native-reanimated": "^2.3.0-beta.2",
"react-native-screens": "^3.8.0",

@bilaltahseen
Copy link

Same error for me , however running in emulator is fine but not working in real device , I am testing on Samsung Note 5

piaskowyk added a commit that referenced this issue Nov 23, 2021
## Description

Animations of disappearing for native stack elements are more complicated, so we decided to disable this type of animation at this moment. It's just a temporary solution. We will come back to this after a stable release.

Fixes: #2460 #2501

Autors: @piaskowyk @WoLewicki 

## Example code

<details>
<summary>example 1</summary>

```js
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import React from 'react';
import {Button, Text, View} from 'react-native';

const Stack = createNativeStackNavigator();

function HomeScreen({navigation}) {
  return (
    <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
      <Text>Home Screen</Text>
      <Button title="navigate" onPress={() => navigation.navigate('Next')} />
    </View>
  );
}

const NextScreen = () => {
  return (
    <View>
      <Text>Some Text</Text>
      <Button title="Navigate" />
    </View>
  );
};

const App = () => {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen name="Home" component={HomeScreen} />
        <Stack.Screen name="Next" component={NextScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
};

export default App;
```
</details>

<details>
<summary>example 2</summary>

```js
import React, { useState } from 'react';
import {Text, View, Button} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';

import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {ReanimatedScreenProvider} from 'react-native-screens/reanimated';
import {createStackNavigator} from '@react-navigation/stack';

const Stack = createStackNavigator();

let mleko = {
  isLogged: false
}

let rerender = null;

const HomeScreen = () => {
  return (
    <View style={{flex: 1}}>
      <View style={{flex: 1, padding: 60}}>
        <Text>Logged</Text>
      </View>
    </View>
  );
};

const LoginScreen = (props: any) => {

  return (
    <View style={{flex: 1}}>
      <View style={{flex: 1, padding: 60}}>
        <Button onPress={() => {
          mleko.isLogged = true;
          rerender(Math.random());
          console.log("mleko");
        }} title="Login" />
      </View>
    </View>
  );
}

export const HomeNavigator = () => {
  return (
    <Stack.Navigator screenOptions={{headerShown: false, gestureEnabled: true}}>
      <Stack.Screen name="Home" component={HomeScreen} />
    </Stack.Navigator>
  );
};

export const LoginNavigator = () => {
  return (
    <Stack.Navigator
      screenOptions={{
        headerShown: false,
        gestureEnabled: true,
      }}>
      <Stack.Screen name="Login" component={LoginScreen} />
    </Stack.Navigator>
  );
};

function RootNavigator() {
  const [a, setA] = useState(1);
  rerender = setA;
  return (
    <Stack.Navigator
      screenOptions={{
        headerShown: true,
        gestureEnabled: true,
      }}>
      {mleko.isLogged ? (
        <Stack.Screen name="HomeNavigator" component={HomeNavigator} />
      ) : (
        <Stack.Screen name="LoginNavigator" component={LoginNavigator} />
      )}
    </Stack.Navigator>
  );
};

const App = () => {
  return (
    <ReanimatedScreenProvider>

      <NavigationContainer>
        <RootNavigator />
      </NavigationContainer>
    </ReanimatedScreenProvider>

  );
};

export default App;
```
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Layout Animations Bug Important This seem to be a serious issue and we will need to take a deeper look into it some time soon Library: Screens 🏠 Reanimated 2
Projects
None yet
Development

Successfully merging a pull request may close this issue.