Search code examples
react-nativereact-reduxreact-native-paper

How do I solve this Error in react-native-paper and Redux?


Error :

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.

I am using react-native-paper and Redux together but I am not able to set up the environment. How to set up the environment to use both at a time?

And yes I linked Dependencies. As when I don't use Redux and pass <App /> in AppRegistery() App works fine. But whenever I wrap <App /> in another component it shows error

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"
  },
  
}

Solution

  • I found the error reason. It is in importing paperProvider. it should be imported from react-native-paper only but I imported from 'react-native-paper/lib/typescript/src/core/settings' so it was causing this current error. actually, it was auto imported by the VScode extension.