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
Conditional rendering of a screen shows a blank screen (new arch) #1628
Comments
Hi @karlmarxlopez, the link to reproduction you provided seems to be outdated / invalid (or maybe the repository is private?). Would you mind updating this? |
I'm having exactly the same issue here! We are using the New Architecture and for now just 4 screens with a basic auth flow as follows,
When the For example, if we are logged out, I can see the LogIn screen fully interactive and shown correctly. After we log in, the |
I'm having the same issue :'c |
@kkafar Hi! I just create a repo reproducing the error: https://github.com/aldiazveGlobant/react-native-screens-stack-error Is an app using the new architecture, just run it and press the button at the bottom; Android works just fine, but iOS renders an empty view and never recovers. Let me know if I can help on anything else! |
RNSScreenStack.mm 代码更改如下 注释下面的代码 下面的代码增加 上面的更改对我有些,希望作者看下是否有用 |
@kkafar can you check this please? It's currently unusable in iOS projects that use conditional rendering on new arch. |
@kkafar can we remove the missing repro label now? It's already provided by @martinraveglia |
@Onedayago node module fix worked for me. Thanks. |
has anyone on android in here, i have same issue with android, it just show empty page but i can see the logs from new screen. |
A partial solution to this issue:
Credits to @Onedayago |
@notmarinho this is not working after release of 0.72 and react native screens new version |
Thanks to @notmarinho his solution worked for now 😄 . But is there any official fix yet? This I have Protected Routes and Auth Routes and when switching Stack with isSignedIn() conditionally it breaks and shows the Blank Screen. <NavigationContainer>
{isAuthenticated() ? <AppStack /> : <AuthStackNavigator />}
</NavigationContainer> |
My solution is also a bit problematic. I hope the official can fix it as soon as possible |
We are also having the same issue on iOS. @Onedayago your solution worked for us, I haven't run into any issues yet. |
@kkafar will an official fix come out soon? |
+1 |
1 similar comment
+1 |
Today I encountered the same issue with my app update to the newest version of react native 0.72.4 and react-native-screens version 3.24.0 with the New Architecture is enabled. The app is working fine in the Old Architecture. |
+1 |
Hi guys! Do you know if this problem still appears in react-native-screens 3.27.0? I just tested the reproduction provided by @aldiazveGlobant and unfortunately I cannot achieve blank screen, even if given components are being rendered conditionally 😕 Screen.Recording.2023-11-20.at.11.06.29.mov |
Hi @tboba! Let me double check and i'll get back to you! Thanks for the reply btw. |
@samuelBenh thank you for providing the info! On which device and OS are you testing your application? Maybe I've got wrong / too newest environment (or the repro does not reflect actual bug) 🤔 |
I tested it on my personal device. I also tested before in my Emulator (Iphone 14 pro, IOS 16.2) Here are the OS version and model of my personal device i tested with: I also add you the others versions of my packages :) |
may be you do not enable fabric
…---Original---
From: "Samuel ***@***.***>
Date: Mon, Nov 20, 2023 23:52 PM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [software-mansion/react-native-screens] Conditional rendering ofa screen shows a blank screen (new arch) (Issue #1628)
@samuelBenh thank you for providing the info! On which device and OS are you testing your application? Maybe I've got wrong / too newest environment (or the repro does not reflect actual bug) 🤔
I tested it on my personal device. I also tested before in my Emulator (Iphone 14 pro, IOS 16.2)
Here are the OS version and model of my personal device i tested with:
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@Onedayago ...yeah 😅 Thanks for pointing that out! |
@samuelBenh in my case I'm still getting blank screen, even on the normal screen 😕 |
Hi guys, I believe I've found the solution for this issue! Could you test whether this change works correctly on your environment? "react-native-screens": "software-mansion/react-native-screens#@tboba/fix-conditional-rendering" cc @SpaghettiC0des @martinraveglia @aldiazveGlobant @aldiazve @Onedayago @cospin @AamirHafiez @notmarinho @affansk @khanakia @Tracht @awmoreira @MaxWesley @jokerhp6789 @ganselu @samuelBenh |
Hello, I changed the package as you mentionned installed my app again. My case was to add back the parameter
When i added it back it is still not doing the transition and brings me to a white screen. :( |
@samuelBenh That's strange 🤔 could you describe how does your scenario like? How does your hierarchy of screens inside navigator look like? Do you have some nested views in modal? |
My app navigation look like this
Inside my Authnavigation i have a screen that have the parameter This modal screen toggle the value that make the transition from the AuthNavigation to the HomeStackNavigation. |
@samuelBenh I assume that AuthNavigation is another nested stack that manages to open fullscreen modal, right? If so, could you also show how that navigation looks like? |
Yess. I removed other stack screen but it looks like this
|
@samuelBenh Great! Thanks for that. I'll try to check that tomorrow and will come with what I've observed soon. |
@samuelBenh I've tried the steps you have provided and I still cannot get working scenario with the blank screen 😕 I'm trying to switch between states and I have no luck with it, unfortunately. Can you correct me if I'm doing something wrong? Screen.Recording.2023-11-30.at.16.05.07.movMy repro: const Home = () => (
<View style={styles.view}>
<Text>This is the initial View</Text>
</View>
);
const NestedHome = () => (
<View style={styles.view}>
<Text>This is nested view!</Text>
</View>
);
const NestedStack = createNativeStackNavigator();
const AuthNavigation = () => (
<NestedStack.Navigator
screenOptions={{ headerShown: false, animation: 'slide_from_right' }}>
<NestedStack.Screen
name="NestedScreen"
component={NestedHome}
options={{
animation: 'slide_from_bottom',
presentation: 'fullScreenModal',
}}
/>
</NestedStack.Navigator>
);
const Stack = createNativeStackNavigator();
const Test1978 = () => {
const [hasChangedState, setHasChangedState] = useState(true);
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{ headerShown: false, animation: 'slide_from_right' }}>
{hasChangedState ? (
<Stack.Screen name="Home" component={Home} />
) : (
<Stack.Screen name="AuthNavigation" component={AuthNavigation} />
)}
</Stack.Navigator>
<TouchableOpacity
style={styles.button}
onPress={() => setHasChangedState(old => !old)}>
<Text>Change state</Text>
</TouchableOpacity>
</NavigationContainer>
);
};
const styles = StyleSheet.create({
button: {
justifyContent: 'center',
alignItems: 'center',
height: 100,
},
view: {
alignItems: 'center',
backgroundColor: '#b7c4bb',
flex: 1,
justifyContent: 'center',
padding: 12,
},
});
export default Test1978; |
Thanks ! You have almost the same setup as me. The only change i notice is maybe that my home navigation is also a nested stack like the AuthNavigation. |
@samuelBenh I tried to make your case more tricky and I changed the logic of opening the fullscreen modal outside of the actual scenario (somehow I cannot open the fullscreen modal while opening AuthNavigation). Unfortunately even if I'm opening the modal I'm still managing to change views conditionally 🤔 Screen.Recording.2023-11-30.at.17.35.26.movI did the same thing with classic modals and changing the condition still works there. Screen.Recording.2023-11-30.at.17.38.28.movtype StackParamList = {
Home: undefined;
AuthNavigation: undefined;
Start: undefined;
ConditionalScreen: undefined;
};
interface MainScreenProps {
navigation: NativeStackNavigationProp<StackParamList>;
}
const Home = () => (
<View style={styles.view}>
<Text>This is the initial View</Text>
</View>
);
const NestedHome = () => (
<View style={styles.view}>
<Text>This is nested view!</Text>
</View>
);
const NestedStack = createNativeStackNavigator();
const OmegaNestedStack = createNativeStackNavigator();
const HomeNavigation = () => (
<OmegaNestedStack.Navigator
screenOptions={{ headerShown: false, animation: 'slide_from_right' }}>
<OmegaNestedStack.Screen
name="NestedScreen"
component={Home}
options={{
animation: 'slide_from_bottom',
}}
/>
</OmegaNestedStack.Navigator>
);
const AuthNavigation = () => (
<NestedStack.Navigator
screenOptions={{ headerShown: false, animation: 'slide_from_right' }}>
<NestedStack.Screen
name="NestedScreen"
component={NestedHome}
options={{
animation: 'slide_from_bottom',
}}
/>
</NestedStack.Navigator>
);
const Stack = createNativeStackNavigator();
const StartStack = createNativeStackNavigator();
const AppView = ({ navigation }: MainScreenProps) => (
<View>
<TouchableOpacity onPress={() => navigation.navigate('ConditionalScreen')}>
<Text>Open me!</Text>
</TouchableOpacity>
</View>
);
const App = () => {
return (
<NavigationContainer>
<StartStack.Navigator>
<Stack.Screen name="Start" component={AppView} />
<Stack.Screen
name="ConditionalScreen"
component={RealTestScenario}
options={{ presentation: 'modal', headerShown: false }}
/>
</StartStack.Navigator>
</NavigationContainer>
);
};
const RealTestScenario = () => {
const [hasChangedState, setHasChangedState] = useState(true);
return (
<>
<Stack.Navigator
screenOptions={{
headerShown: false,
animation: 'slide_from_right',
}}>
{hasChangedState ? (
<Stack.Screen name="Home" component={HomeNavigation} />
) : (
<Stack.Screen name="AuthNavigation" component={AuthNavigation} />
)}
</Stack.Navigator>
<TouchableOpacity
style={styles.button}
onPress={() => setHasChangedState(old => !old)}>
<Text>Change state</Text>
</TouchableOpacity>
</>
);
};
const styles = StyleSheet.create({
button: {
justifyContent: 'center',
alignItems: 'center',
height: 100,
},
view: {
alignItems: 'center',
backgroundColor: '#b7c4bb',
flex: 1,
justifyContent: 'center',
padding: 12,
},
});
export default App; |
@tboba Thank you - I tried your fix and can confirm that it works in my app. There is a remaining issue where the screens switch over immediately and don't respect the If we use this example from the react-navigation documentation:
The pop/push animation is not applied in this case. |
@rzckztman thanks for confirming this works for you! |
Looks like I was wrong above 😄 Me and @WoLewicki have managed to try different approach and we've decided to completely disable view recycling for screens! The PR is open and should be merged soon 🎉 I'm attaching the result of the solution below. Here you can see, that the screen on the top is being replaced successfully, and even with the animation! We've also covered a small workaround in rare situations, where Please note that this solution will work for RN versions equal or higher than 0.74, since we're disabling view recycling there thanks to the method Screen.Recording.2024-03-20.at.16.00.00.mov |
## Description PR disabling view recycling from `RNSScreenView` component. It also enables us to fix long lasting issue with view recycling. This feature was added in RN 0.74 and will only work then. Fixes #1628. ## Changes - stop recycling `RNSScreenView` - Remove logic connected to problems with view recycling - Change the logic of setting push view controllers on new architecture, when transition is ongoing - Add if check for cases, when user navigates to more than one screen at the same time ## Test code and steps to reproduce See that modals and `replace` action work correctly. You can also use `Test2069.tsx` from FabricTestExample / TestsExample to test the behavior of replacing screens conditionally. --------- Co-authored-by: tboba <tymoteusz.boba@gmail.com>
Description
Related to #690
I'm playing around with new architecture and the native stack navigator, and I encountered this issue. It's working properly when using the JS based stack navigator.
I have a simple redux state
isLoggedIn
which is just a simpleboolean
flag to simulate an authenticated user. I have a button to toggle the state to replaceAuthStack
with theMainStack
. You know, the classic architecture for auth flow with react-navigation. More info on the official docs.Steps to reproduce
Just follow the example here https://reactnavigation.org/docs/auth-flow/#define-our-screens
Snack or a link to a repository
https://github.com/karlmarxlopez/rn-navigation-native-stack-new-arch-issue
Screens version
3.18.2
React Native version
0.70.4
Platforms
iOS
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Fabric (New Architecture)
Build type
Debug mode
Device
iOS simulator
Device model
iPhone 14 Pro
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: