react-native-screens: Fabric UIViewControllerHierarchyInconsistency A view can only be associated with at most one view controller at a time! View
getting this error only when I enable the fabric
name __NSCFConstantString * “UIViewControllerHierarchyInconsistency” 0x000000020be3fdf0
Exception NSException * “A view can only be associated with at most one view controller at a time! View <RNSScreenView: 0x113814000; frame = (0 0; 0 0); layer = <CALayer: 0x2812ead00>> is associated with <RNSScreen: 0x111e15f20>. Clear this association before associating this view with <RNSScreen: 0x11d6873f0>.” 0x0000000281d4e4f0
here is my code
const TestComponent = () => {
return <Text>TestComponent</Text>;
};
const App = () => {
return (
<NavigationContainer>
<RootStack.Navigator
screenOptions={{
headerHideBackButton: true,
}}
>
<RootStack.Screen
name="Chapter"
options={{
title: "Fabric Example",
headerShown: false,
}}
initialParams={{
index: 0,
chapterRoute: "Chapter",
afterChapterRoute: "HeaderDemo",
}}
component={TestComponent}
/>
<RootStack.Screen
name="HeaderDemo"
component={TestComponent}
options={{ title: "Header Demo" }}
/>
</RootStack.Navigator>
</NavigationContainer>
);
};
export default App;
"react-native": "0.72.1",
"react-native-screens": "3.22.0",
here is repro: https://github.com/numandev1/UIViewControllerHierarchyInconsistency-error-repro
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 31 (8 by maintainers)
hi there! this is kudo from expo. thanks for the investigation and sorry to have the issue in our side.
EXReactCompatibleHelpers.m
i’m creating https://github.com/expo/expo/pull/24004 to fix that. in the meantime, please try to apply the patch to continue the testing.react-native-gesture-handler issue not sure why the old issue comes up again. i have to enable the inlinesRequires
after these modifications, i can launch the app but i did not see the
A view can only be associated with at most one view controller at a time!
error.I’ve brought this up with the Expo team and they are looking at it internally as well, will keep you posted
I’ve spent some time debugging it and it seems to me that Expo is responsible for this issue. Few things I’ve managed to find up to this moment (will debug it further):
EXReactCompatibleHelpers.m
ifdef statement_has_include(<React/RCTAppSetupUtils.h>)
does not work as expected – it does not discover the header despite it being present in project, thus wrong application root view is created. Exchanging angle-bracket include for quote form resolves the issue, thus conclusion that some include search paths are misconfigured.indicating that
nativeFabricUIManager
was not injected toglobal
from native side ==> Expo most likely interferes with process of creation & setup of turbo modules.I would recommend opening issue on Expo’s repo.
I’ll leave this issue open until I’m convinced that there is nothing to be done on
react-native-screens
side.@kkafar can you pls check ignite’s boilerplate? Facing the same issue there
Please ignore this now. Looks like I ran into https://github.com/expo/expo/issues/23382 and removing
expo-updates
fixed the crash. 🙏@Kudo @kkafar I can confirm that after patching those two files, Fabric successfully runs without that issue now. It definitely seems related to gesture-handler as the demo Ignite code which incorporates it is acting odd when using
DrawerLayout
(it opens by default when the screen renders and remains stuck in the open position).But otherwise things generally seem functional. Here is the repo: https://github.com/frankcalise/IgniteFabricIos
In addition to the
expo-modules-core
patch, this was the metro.config.js used:@kkafar I created a reproduction repo. Just call
yarn install && yarn bundle-install && yarn pod-install && yarn ios
. That will reproduce the problem. Thanks everyone.@kkafar sorry, fixed now, can you check now
hey @kkafar - you can reproduce this issue using the next version of Ignite
set up a new project with (should be alpha5)
answer prompt on what directory you want it,
cd
after install and then run viayarn ios