react-native - 如何解决 react-native-paper 和 Redux 中的这个错误?

标签 react-native react-redux react-native-paper

错误:

Error: Unable to resolve module react-native-paper/lib/typescript/src/core/settings from index.js: react-native-paper/lib/typescript/src/core/settings could not be found within the project.

我正在使用 react-native-paperRedux在一起,但我无法设置环境。如何设置同时使用两者的环境?

是的,我链接了依赖项。当我不使用 Redux 并传递 <App /> 时在 AppRegistery()应用程序运行良好。但每当我包装 <App />在另一个组件中显示错误

index.js:

/**
 * @format
 */

import {AppRegistry} from 'react-native';
import App from './App';
import { Provider as StoreProvider} from 'react-native-paper/lib/typescript/src/core/settings';
import { Provider as PaperProvider } from 'react-native-paper';


const store = createStore(RootReducer,applyMiddleware(thunk))


export default function MyApp() {
    return (
      <StoreProvider store = {store}>
          <PaperProvider>
            <App />
          </PaperProvider>
      </StoreProvider>
    );
  
}


AppRegistry.registerComponent(appName, () => MyApp);

package.json:

{
  "dependencies": {
    "@react-native-community/async-storage": "^1.11.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-firebase/app": "^7.2.0",
    "@react-native-firebase/auth": "^8.0.4",
    "@react-navigation/material-bottom-tabs": "^5.2.10",
    "@react-navigation/native": "^5.5.0",
    "@react-navigation/stack": "^5.4.2",
    "react": "16.11.0",
    "react-native": "0.62.2",
    "react-native-elements": "^2.0.2",
    "react-native-gesture-handler": "^1.6.1",
    "react-native-paper": "^3.10.1",
    "react-native-reanimated": "^1.9.0",
    "react-native-safe-area-context": "^3.0.2",
    "react-native-screens": "^2.8.0",
    "react-native-simple-toast": "^1.1.2",
    "react-native-tab-view": "^2.14.4",
    "react-native-vector-icons": "^6.6.0",
    "react-redux": "^7.2.0",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0"
  },
  
}

最佳答案

我找到错误原因了。它在导入 paperProvider 中。它应该只从 react-native-paper 导入,但我从 'react-native-paper/lib/typescript/src/core/settings' 导入所以它导致这个当前错误。实际上,它是由 VScode 扩展程序自动导入的。

关于react-native - 如何解决 react-native-paper 和 Redux 中的这个错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62472049/

相关文章:

swift - 我怎样才能从 native react 中获取值(value)到我的桥梁快速类(class)中?

ios - react native : Module AppRegistry is not a registered callable module (calling runApplication)

react-native - React Native - headless JS 示例

node.js - 离开屏幕回调 React Navigation Tab Navigator

reactjs - 错误: Expected the reducer to be a function

react-native - FontFamily "Material Design Icons"不是系统字体,尚未通过 Font.loadAsync 加载

reactjs - 如何在 React Native 应用程序启动时组合多个任务

javascript - 在 React-Redux 中实时重新排序列表的最佳方法?

react-native - 如何更改react-native-paper的DataTable中表格列的宽度

react-native - 安装 react-native-paper 后配置损坏