recently looking at the react-related technology stack, I feel that a lot of things seem a little laborious.
such as the related use of redux-saga, as follows:
import { createStore, combineReducers, applyMiddleware } from "redux";
import userNameReducer from "../username/reducer.js";
import createSagaMiddleware from "redux-saga";
import rootSaga from "./saga.js";
const sagaMiddleware = createSagaMiddleware() // create/ sagaMiddleware
const reducerAll = {
userNameReducer: userNameReducer
}
export const store = createStore(
combineReducers({...reducerAll}), // fn()reducer
window.devToolsExtension ? window.devToolsExtension() : undefined,
applyMiddleware(sagaMiddleware) // applyMiddlewaresagaMiddlewarecreateStorefnAfnA({},fnB(fnC))fn()
)
sagaMiddleware.run(rootSaga) // sagaMiddlewarerunrunrootSagafnA(fnB)
there are two problems:
-
Why can"t createSagaMiddleware in
- import createSagaMiddleware from "redux-saga"; be used directly like deepClone () in import {deepClone} from" lodash";? Instead, you need to return the function to a new function in the form of fnA (fnB), and then use it.
- this kind of fnA ({}, fnB (fnC (fnD), {})) this way of writing looks so difficult to understand.
ask the bosses for advice.