DEV Community

seema techdoodles
seema techdoodles

Posted on

TypeError: undefined is not a function. Error i applyMiddleware in redux

I am upgrading my expo version from 48 to 51. App buid 100% but after that it gives error in applyMiddleWare() function
TypeError: undefined is not a function,
in my configstore.js

Steps to Reproduce
when i run sudo npx expo start --go
then android build 100% but then this issue occur

Environment Details
"react-redux": "8.1.1",
"redux": "4.2.1",
"redux-actions": "2.6.5",
"redux-persist": "6.0.0",
"redux-thunk": "2.4.1",
"expo": "~51.0.6",
i am working on macOS

this is my ConfigStore file code

`

`
/** @format */
import Reactotron from 'reactotron-react-native';
import { applyMiddleware, compose, createStore } from 'redux';
import thunk from 'redux-thunk';

import reducers from '@redux';
import { Constants } from '@common';
import { connectConsoleToReactotron, DEV_ENV } from '@app/Omni';
import './../../ReactotronConfig';

const middleware = [
thunk,
// more middleware
];

// const store = createStore(reducers, {}, applyMiddleware(...middleware));

const configureStore = () => {
let store = null;
if (DEV_ENV) {
if (Constants.useReactotron) {
store = createStore(
reducers,
{},
compose(applyMiddleware(...middleware), Reactotron.createEnhancer()),
);
connectConsoleToReactotron();
} else {
const composeEnhancers =
window.REDUX_DEVTOOLS_EXTENSION_COMPOSE || compose;
store = composeEnhancers(applyMiddleware(...middleware))(createStore)(
reducers,
);

  if (module.hot) {
    // Enable Webpack hot module replacement for reducers
    module.hot.accept(reducers, () => {
      const nextRootReducer = reducers;
      store.replaceReducer(nextRootReducer);
    });
  }

  // show network react-native-debugger
  // only show on IOS, android bug
  // if (Platform.OS === "ios") {
  global.XMLHttpRequest = global.originalXMLHttpRequest
    ? global.originalXMLHttpRequest
    : global.XMLHttpRequest;
  global.FormData = global.originalFormData
    ? global.originalFormData
    : global.FormData;
}
Enter fullscreen mode Exit fullscreen mode

} else {
store = compose(applyMiddleware(...middleware))(createStore)(reducers);
}
return store;
};

export default configureStore();

Image description

Sentry blog image

The Visual Studio App Center’s retiring

But sadly….you’re not. See how to make the switch to Sentry for all your crash reporting needs.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay