When you start an asynchronous actoin after running the react project after build, you are prompted that you do not use middleware.

There is no problem with

build running before. After
is run with serve, this error is reported by initiating an asynchronous action. The middleware used by
is redux-thunk.
error message:

Uncaught Error: Actions must be plain objects. Use custom middleware for async actions.
    at Object.performAction (<anonymous>:1:40685)
    at liftAction (<anonymous>:1:34238)
    at dispatch (<anonymous>:1:38232)
    at Object.getSingleSearchResult (index.jsx:207)
    at t.value (index.jsx:44)
    at fa (react-dom.production.min.js:5065)
    at da (react-dom.production.min.js:4826)
    at ca (react-dom.production.min.js:4800)
    at va (react-dom.production.min.js:5202)
    at En (react-dom.production.min.js:1737)

store.js file:

import { createStore, applyMiddleware, compose } from "redux";
import reducer from "./reducer/";
import thunk from "redux-thunk";


const win = window;

const middlewares = [];
if (process.env.NODE_ENV !== "production") {
  middlewares.push(thunk);
}

const storeEnhancers = compose(
  applyMiddleware(...middlewares),
  (win && win.devToolsExtension) ? win.devToolsExtension() : (f) => f
);


export default createStore(reducer, storeEnhancers); 

Project address: Link description
what is the cause? Thank you

Sep.23,2021

just wrote the file like this. What's going on?

import { createStore, applyMiddleware, compose } from 'redux';
import reducer from './reducer/';
import thunk from 'redux-thunk';


export default createStore(reducer, applyMiddleware(thunk)); 

if (process.env.NODE_ENV !== 'production') {
  middlewares.push(thunk);
}

here is the judgment of the environment. If the environment is not production , or thunk middleware is used, the mode should be modified in the packaged configuration, resulting in process.env.NODE_ENV=production , so the thunk plug-in does not exist in production .

so why not use thunk` under production ?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3d313-4da11.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3d313-4da11.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?