react-native-offline: could not find "store"

I always get this error although i wrapped my component in redux provider screen shot 2019-01-07 at 8 09 37 pm

my code `export default class App extends Component {

render() {

return (

  <Provider store={store}>

  <ReduxNetworkProvider >

    <WelcomeSwitch />

  </ReduxNetworkProvider>   

  </Provider>

);

} } `

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 31 (4 by maintainers)

Most upvoted comments

@souvik-ghosh, @ghorbani-m, @abudahsh, @gams95 could you please tell me the versions of react-redux that you are using?

My guess is that you need to upgrade react-redux to the latest, 6.0.0. If you are using v5.x, it won’t work because the don’t support the new React Context API that this library leverages. I glanced at the breaking changes and nothing major, therefore the upgrade should be smooth.

Please confirm and I’ll add that documentation to the docs.

My “react-redux”: “^7.1.0” and got same issues

Same error here with react-redux 7.0.4 and react-navigation.

@rgommezz any example on how to implement ReduxNetworkProvider with PersistGate from redux-persist?

Stil have error onreact-redux v7.1.1

I’m experiencing this problem, and upgrading react-redux didn’t help 😃

Versions: react-native-offline@4.1.2 react-redux@6.0.0 react@16.6.1

stores.js

import { createStore, applyMiddleware } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
import thunkMiddleware from "redux-thunk";
import { createNetworkMiddleware } from "react-native-offline";
import root from "../reducers/root";

const finalCreateStore = composeWithDevTools(
  applyMiddleware(createNetworkMiddleware(), thunkMiddleware)
)(createStore);
const store = finalCreateStore(root);

export default store;

app.js

import React from "react";
import {
  View,
  Dimensions,
  NetInfo,
  BackHandler,
  StatusBar
} from "react-native";
import { Router, Route } from "react-router-native";
import { Provider } from "react-redux";
import { ThemeContext, getTheme } from "react-native-material-ui";
import { ReduxNetworkProvider } from "react-native-offline";
import store from "./stores";
import styles from "./styles";

class App extends React.Component {
  render() {
    return (
      <Provider store={store}>
        <ReduxNetworkProvider>
          <ThemeContext.Provider value={getTheme(uiTheme)}>
            <Router history={history}>
              <View
                style={styles.container}
              >
                <Route exact path="/" component={Intro} />
                <Route path="/signup" component={Signup} />
                <Route path="/login" component={Login} />
                <Route path="/board" component={Main} />
              </View>
            </Router>
        </ThemeContext.Provider>
       </ReduxNetworkProvider>
      </Provider>
    );
  }
}

export default App;

Am I doing anything wrong?

For all people having this error, be careful to have only one version of react-redux in your dependencies lock file (yarn.lock or package-lock.json).

Installing this (amazing) package added another version of react-redux than the one in my package.json, and turned into this issue. So, I fixed it setting react-redux to a fixed version (to only have one version resolved).

Hope this help 👍

What it worked for me is removing the react-redux dependency of my own project.

npm un react-redux npm i react-native-offline

This way you make sure there’s only one version of react-redux.

For all people having this error, be careful to have only one version of react-redux in your dependencies lock file (yarn.lock or package-lock.json).

Installing this (amazing) package added another version of react-redux than the one in my package.json, and turned into this issue. So, I fixed it setting react-redux to a fixed version (to only have one version resolved).

Hope this help 👍

Thank you for this answer. This works but in my opinion this is not error safe for future development of the app. I fixed versions of packages to

"react-redux": "7.1.3",
"react-native-offline": "5.2.0",

I had react-redux in version 7.1.0 previously but offline package kept installing it’s own version 7.1.3 then I’ve added this version to whole app. If I wouldn’t freeze react-native-offline version I assume it would update it’s dependencies in future updates and crash the app again.

Noticed a similar problem, solved it with @VincentCATILLON solution + made sure that my package.json had the same version.

@rgommezz Yup, react-redux v5 was causing the problem. Got up and running with v6.

@gams95 Yes, I have used the “createSwitchNavigator” to initiate my App.

@rgommezz I have the same error too.