Skip to content

Commit 59c9a64

Browse files
author
soliury
committed
only isDebuggingInChrome the logger can work
1 parent c618206 commit 59c9a64

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/store/configureStore.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,27 @@ import promiseMiddleware from './promiseMiddleware';
44
import asyncActionCallbackMiddleware from './asyncActionCallbackMiddleware';
55
import utilsMiddleware from './utilsMiddleware';
66
import minPendingTimeMiddleware from './minPendingTime';
7-
import logger from 'redux-logger';
7+
import createLogger from 'redux-logger';
88
import reducers from '../reducers';
99

1010

11-
var middlewares = [
11+
const isDebuggingInChrome = __DEV__ && !!window.navigator.userAgent;
12+
const logger = createLogger({
13+
predicate: (getState, action) => isDebuggingInChrome,
14+
collapsed: true,
15+
duration: true
16+
});
17+
18+
const middlewares = [
1219
thunkMiddleware,
1320
promiseMiddleware,
1421
asyncActionCallbackMiddleware,
1522
minPendingTimeMiddleware,
16-
utilsMiddleware
23+
utilsMiddleware,
24+
logger
1725
];
1826

1927

20-
if (__DEV__) {
21-
middlewares.push(logger());
22-
}
23-
24-
2528
export default function configureStore(initialState) {
2629
const store = applyMiddleware(
2730
...middlewares
@@ -34,6 +37,10 @@ export default function configureStore(initialState) {
3437
});
3538
}
3639

40+
if (isDebuggingInChrome) {
41+
window.store = store;
42+
}
43+
3744
return store;
3845
}
3946

0 commit comments

Comments
 (0)