I'm trying to install redux-logger by following actions:
npm install --save redux-logger
after that I added import logger to the code:
import logger from 'redux-logger'
and then I included logger to the applyMiddleware:
const createStoreWithMiddleware = applyMiddleware(thunk, logger)(createStore)
const reducer = combineReducers(reducers)
const store = createStoreWithMiddleware(reducer, undefined, autoRehydrate())
persistStore(store, persistConfig)
But I get an error that it's not installed. Does anybody know why it happens?
Be sure that react-native's packager is shut down. npm/yarn will get stuck or most likely show you an error if you don't shut it down while installing new modules.
If that's your only middleware, you can do as @Amassuo suggested.
import createLogger from 'redux-logger'
const logger = createLogger();
const store = createStore(
reducers,
applyMiddleware(logger)
);
i just used createlogger , gave it no options, it works fine, this will help you Log and debug, until someone figure it out for us ,
import createLogger from 'redux-logger'
const logger = createLogger({
//empty options
});
const store = createStore(
reducer,
applyMiddleware(logger)
);
Strangely, i did an
npm install 'redux-logger'
and got the above error. Curious, i visited the redux-logger npm homepage and noticed the latest version was 3.0.6, but the npm default install pulled down ^2.10.2. I solved this by manually specifying 3.0.6 in my package.json and it fixed the issue after an npm install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With