1
votes

I want to pass multiple enhancer functions to the createStore function of Redux.

This approach did NOT worked:

const store = createStore(rootReducer, [composeWithDevTools(), applyMiddleware()]); // !!!!! Remove composeWith Dev FOR RELEASE

this was worked when i only passed the DevTools enhancer:

const store = createStore(rootReducer, composeWithDevTools());

im working with React Native for information. How can i pass multiple Enhancer to the CreateStore function? Thank you for your help

EDIT: - SOLVED

after some trying and getting some knowledge about composers (thanks to the tip from the answere) i found the right usage:

const store = createStore(rootReducer, composeWithDevTools(applyMiddleware(ReduxThunk)));
1

1 Answers

1
votes

It seems like you want the compose function from redux. Here's an example with many enhancers, which is also documented in the Redux "Configuring Your Store" docs page.

import { applyMiddleware, compose, createStore } from 'redux'
import thunkMiddleware from 'redux-thunk'

const middlewareEnhancer = applyMiddleware(loggerMiddleware, thunkMiddleware)

const composedEnhancers = compose(middlewareEnhancer, monitorReducersEnhancer)

const store = createStore(rootReducer, preloadedState, composedEnhancers)