enter image description here
这文件是可用的如你能看见.我不知道whyh这错误是coming up.这错误说这文件不能是发现在这文件夹,但是它是清楚地有
import { nanoid } from 'nanoid/non-secure';
import * as React from 'react';
import { SingleNavigatorContext } from './EnsureSingleNavigator';
/**
* Register a navigator in the parent context (either a navigation container or a screen).
* This is used to prevent multiple navigators under a single container or screen.
*/
export default function useRegisterNavigator() {
const [key] = React.useState(() => nanoid());
const container = React.useContext(SingleNavigatorContext);
if (container === undefined) {
throw new Error(
"Couldn't register the navigator. Have you wrapped your app with 'NavigationContainer'?\n\nThis can also happen if there are multiple copies of '@react-navigation' packages installed."
);
}
React.useEffect(() => {
const { register, unregister } = container;
register(key);
return () => unregister(key);
}, [container, key]);
return key;
}
这是我的依赖项列表
"dependencies": {
"@expo/vector-icons": "^12.0.5",
"expo": "~44.0.0",
"expo-app-loading": "^1.3.0",
"expo-font": "^10.0.5",
"expo-status-bar": "~1.2.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-reanimated": "~2.3.1",
"react-native-web": "0.17.1",
"react-navigation": "^3.0.0",
"react-navigation-header-buttons": "^8.0.0",
"react-redux": "^7.2.8",
"redux": "^4.1.2",
"redux-devtools-extension": "^2.13.9"
},
1条答案
按热度按时间2sbarzqh1#
我也遇到了同样的问题,我刚刚意识到我改变了
babel.config.js
中的预置默认情况下是
presets: ['babel-preset-expo'],
,我将其更改为presets: ['module:metro-react-native-babel-preset'],
尝一个吧。第一个对我管用。