0

当我包含这个包然后在我的页面组件中添加一个链接时,它给了我一个错误。在世博会客户端工作正常。这里我想使用 expo-next-react-navigation 包。错误链接https://github.com/nandorojo/expo-next-react-navigation/issues/72

错误 在此处输入图像描述

漏洞

包.json

{
  "dependencies": {
    "@react-navigation/native-stack": "^6.0.3",
    "expo": "~42.0.0",
    "expo-next-react-navigation": "^1.1.14",
    "next": "^11.0.1",
    "next-offline": "^5.0.5",
    "next-optimized-images": "^2.6.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "~3.4.0",
    "react-native-web": "^0.17.1",
    "setimmediate": "^1.0.5"
  },
  "devDependencies": {
    "@babel/core": "^7.14.6",
    "@expo/next-adapter": "^3.0.1",
    "@types/react": "^17.0.16",
    "@types/react-native": "^0.64.12",
    "eslint": "^7.32.0",
    "eslint-config-next": "^11.0.1",
    "next-compose-plugins": "^2.2.1",
    "next-transpile-modules": "^8.0.0",
    "typescript": "^4.3.5",
    "webp-loader": "^0.6.0"
  },
  "scripts": {
    "start": "next dev",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "build": "next build",
    "next-lint": "next lint"
  },
  "private": true
}

` .eslintrc

{
    "extends": ["next", "next/core-web-vitals"]
  }

通天塔配置

module.exports = { presets: ['@expo/next-adapter/babel'] };

自定义组件

const Link = React.forwardRef(function Link(props, ref) {
    const { nextLinkProps = empty.object, style, params = empty.object, children, isText = true, web, } = props;
    const query = useMemo(() => ({ ...params }), [params]);
    const webPath = web?.path?.[0] === '/' ? web?.path?.slice(1) : web?.path;
    const pathname = `/${webPath ?? props.routeName}`;
    const href = useMemo(() => ({
        query,
        pathname,
    }), [pathname, query]);
    return (<NextLink passHref {...nextLinkProps} href={href} as={web?.as} prefetch={web?.prefetch} scroll={web?.scroll} replace={web?.replace} shallow={web?.shallow}>
        {isText ? (<Text ref={ref} accessibilityRole="link" style={style}>
            {children}
          </Text>) : (<View accessibilityRole="link" style={style}>
            {children}
          </View>)}
      </NextLink>);
});
export default Link;
4

0 回答 0