0

Repo: https://github.com/jerzy-jarczynski/backend_rest_api_app

I'm trying to deploy an Express.js and React application on Replit. The application is working fine on localhost, and I can also see it using the following link: https://backendrestapiapp.jerzy-jarczynski.repl.co/

However, when I open it in an incognito tab or on other devices, I encounter the following error:

redux.js:621 Uncaught TypeError: Cannot read properties of undefined (reading 'apply')
at redux.js:621:18
at e (redux.js:154:12)
at store.js:14:15
at index.js:20:51
at index.js:20:51

Instead of displaying the application, I see a blank screen.

I tried changing the Node.js version in the .replit file using the following configuration:

run = "nvm install 16.18.0 && nvm use 16.18.0 && node server.js"

I also attempted to install the Redux libraries with the --legacy-peer-deps flag:

npm install redux react-redux --legacy-peer-deps

On Replit, the Node.js version is higher:

~/backendrestapiapp$ node -v
v18.12.1

So, I tested this version locally, but I didn't encounter the same Redux error.

  • Your app doesn't work on development server anyway ([proof](https://prnt.sc/ktI9s2OGjNCT)). So I'd suggest checking the source code first. – msrumon Jul 09 '23 at 14:34
  • Sure, could You give me some hint what to check at first? – Jerzy Jarczynski Jul 09 '23 at 14:48
  • I don't know React. However, based on the error stack, I'd probably start looking into `createStore()` call at line 14 in **client/src/redux/store.js**. – msrumon Jul 09 '23 at 15:03
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Jul 09 '23 at 16:58

1 Answers1

0
import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';

// import reducers
import concerts from './concertsRedux';
import seats from './seatsRedux';

// combine reducers
const rootReducer = combineReducers({
  concerts,
  seats,
});

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
  rootReducer,
  composeEnhancers(applyMiddleware(thunk))
);

export default store;

This is corrected store.js and it seems to work correctly on Replit.