【问题标题】:How do I solve this Error in react-native-paper and Redux?如何解决 react-native-paper 和 Redux 中的此错误?
【发布时间】:2020-06-19 14:07:02
【问题描述】:

错误:

错误:无法从 index.js 解析模块 react-native-paper/lib/typescript/src/core/settings:在项目中找不到 react-native-paper/lib/typescript/src/core/settings。

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

是的,我链接了依赖项。当我不使用 Redux 并在 AppRegistery() 中传递 <App /> 时,应用程序工作正常。但是每当我将<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"
  },
  
}

【问题讨论】:

  • 错误发生在安卓还是iOS?在网络上?你linked 打包了吗?
  • @HagaiHarari 它在安卓上。是的,我链接了依赖项。当我不使用 Redux 并在 AppRegistery() 中传递 时,应用程序工作正常。但是每当我将 包装在其他组件中时,它都会显示错误

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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2021-06-17
    • 2018-12-25
    • 2022-07-25
    • 1970-01-01
    • 1970-01-01
    • 2021-03-09
    • 2020-06-29
    • 2020-01-26
    • 2019-09-18
    相关资源
    最近更新 更多