Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用多applyMiddleware进行React Redux_Javascript_Reactjs_React Native_Redux_Redux Thunk - Fatal编程技术网

Javascript 使用多applyMiddleware进行React Redux

Javascript 使用多applyMiddleware进行React Redux,javascript,reactjs,react-native,redux,redux-thunk,Javascript,Reactjs,React Native,Redux,Redux Thunk,我想用下面的答案 但是我不理解这里的javascript语法 他如何使用compose(argument)(createStore)(argument) 是否有类似于createStore(reducer、initialState、compose(argument))的替代方案 另外,初始状态将如何在此处传递 const createStoreWithMiddleware = compose( applyMiddleware(thunkMiddleware) )(createStore

我想用下面的答案

但是我不理解这里的javascript语法 他如何使用
compose(argument)(createStore)(argument)

是否有类似于
createStore(reducer、initialState、compose(argument))
的替代方案

另外,初始状态将如何在此处传递

const createStoreWithMiddleware = compose(  
  applyMiddleware(thunkMiddleware)
)(createStore);

export default function configureStore(initialState) {  
  const store = createStoreWithMiddleware(rootReducer);
  return store;
}
对!!
enhancer()(createStore)
语法是使用
createStore
的老式方式,我们正试图鼓励人们使用更新的语法:

const composedEnhancers = compose(
    firstEnhancer,
    secondEnhancer
);

const store = createStore(
    rootReducer,
    preloadedState,
    composedEnhancers
);

compose返回与第一个参数具有相同签名的函数-createStore,然后使用第二个参数调用该函数。-减速器和初始state@ReiDien有关于javascript中这种语法的教程吗?我没有。也许对函数的深入理解可以帮助您解决复杂的问题您知道像func1(arg)func2(arg)这样的javascript函数的源代码吗?这是一种称为“currying”的函数编程方法,或者可能只是一个返回另一个函数的函数。我有一些可能有用的链接。
const composedEnhancers = compose(
    firstEnhancer,
    secondEnhancer
);

const store = createStore(
    rootReducer,
    preloadedState,
    composedEnhancers
);