React Native TypeError store.getState is not a function

Wesley Guirra

Hi guys I'm trying to make my code more readable and pragmmatic.

Using redux-saga in React Native I'm getting some issues.

When I try to load the app I get the error:

TypeError: store.getState is not a function

This error is located at:

in Connect(Reprov) (at App.js:17)
in RCTView (at View.js:44)
in Provider (at App.js:14)
in App (at renderApplication.js:34)
in RCTView (at View.js:44)
in RCTView (at View.js:44)
in AppContainer (at renderApplication.js:33)

src/store/configureStore.js


import {createStore, applyMiddleware} from 'redux'
import createSagaMiddleware from 'redux-saga';
import rootReducer from '../reducers';
import rootSaga from '../sagas';

export default function () {
  const sagaMiddleware = createSagaMiddleware();
  const store = createStore(
    rootReducer,
    applyMiddleware(sagaMiddleware)
  );

  sagaMiddleware.run(rootSaga)

  return store;
}

src/App.js

import React, {Component} from 'react'
import { View } from 'react-native';
import { Provider } from 'react-redux';
import AppNavigation from './Navigation';
import store from './store/configureStore';
import Reproof from './screens/Reprov';
import Approval from './screens/Aprov';
import PushNotificationController from './components/Push';

class App extends Component {
  render() {
    return (
      <Provider store={store}>
        <View style={{ flex: 1 }}>
          <AppNavigation />
          <Reproof />
          <Approval />
          <PushNotificationController />
        </View>
      </Provider>
    )
  }
}

export default App;

I don't know what I'm doing wrong...

LHIOUI

You are importing the store as a variable and in the file,it is a function :

import store from './store/configureStore';

try this :

import configureStore from './store/configureStore';

then create a variable store

const store = configureStore();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TypeError: store.getState is not a function in react-redux

react-redux : TypeError: store.getState is not a function

TypeError: store.getState is not a function. (In 'store.getState()', 'store.getState' is undefined

Uncaught TypeError: store.getState is not a function

TypeError: store.getState is not a function (redux)

TypeError: store.getState is not a function. (In 'store.getState()', 'store.getState' is undefined how can i resolve this problem?

I am getting this error: TypeError: store.getState is not a function

TypeError: _this.store.getState is not a function when using connect from Redux

store.getState is not a function

TypeError: undefined is not an object (evaluating 'store.getState')

TypeError : submitHandler is not a function on React Native

store.getState is not a function Redux-persist

TypeError: getState is not a function when adding middleware to Redux

React Native: Call Redux getState() inside Component

TypeError: “FunctionName” is not a function async and await - React Native

React Native: TypeError: babelHelpers.typeof is not a function

TypeError: dispatcher.useState is not a function for React Native

"TypeError: _this2.setState is not a function" React Native

TypeError : Object (...) is not a function react native stack navigation

Redux: Calling store.getState() in a reducer function, is that an anti pattern?

TypeError: getState is not a function in redux when trying to pass token

How to store return value of function in a variable in react-native

TypeError: middleware is not a function in store

mocking store.getState()

TypeError: _ReanimatedModule.default.animateNextTransition is not a function in React-native-navigation

TypeError: element.setAttribute is not a function (React Native / Three.js)

TypeError: (0, _reactNavigation.default) is not a function. React Native

React Native , Redux - TypeError: (0 , _redux.createStore) is not a function

TypeError: (0, _reactNavigationDrawer.createAppContainer) is not a function: React Native Error