3

我在以下期间得到以下信息npm test

console.warn node_modules/react-navigation/src/react-navigation.js:23
      `createNavigationContainer()` has been deprecated, please use `createAppContainer()` instead. You can also import createAppContainer directly from @react-navigation/native
console.warn node_modules/react-navigation/src/react-navigation.js:161
      Importing the stack Transitioner directly from react-navigation is now deprecated. Instead, import { Transitioner } from "react-navigation-stack";

这在模拟导航模块后出现,这是我的__mocks__/react-navigation.tsx文件:

import React from "react";
import { SafeAreaViewProps } from "react-navigation";

jest.mock("react-navigation", () => ({
  ...require.requireActual("react-navigation"),
  NavigationEvents: "mockNavigationEvents",
  withNavigation: (Component: React.ComponentClass) => (props: any) => (
    <Component navigation={{ navigate: jest.fn() }} {...props} />
  ),
  SafeAreaView: ({ children }: SafeAreaViewProps) => <>{children}</>,
  ThemeColors: {
    light: {
      label: "rgba(0, 0, 0, 0.9)",
      bodyContent: "",
    },
    dark: {
      body: "rgba(0, 0, 0, 0.9)",
      bodyContent: "",
    },
  },
}));
module.exports = require.requireMock("react-navigation");

我做错了什么?你能帮忙吗?

反应导航版本:3.11.0

4

0 回答 0