wagtail/client/src/utils/performance.js
Janneke Janssen 28dd28187a Update React and related dependencies to latest versions
Updated snapshots due to the upgrade and failing ExplorerPanel test. This was due to the shallow call being made earlier than defining the document.body
Update to React 16
Update other dependencies
Stylelint updates
Remove unused imports
Update babel and gulp packages
Update package-lock
2018-01-17 21:48:17 +02:00

33 lines
769 B
JavaScript

/* eslint-disable import/no-mutable-exports */
let perfMiddleware;
if (process.env.NODE_ENV !== 'production') {
/**
* Performance middleware for use with a Redux store.
* Will log the time taken by every action across all
* of the reducers of the store.
*/
perfMiddleware = () => {
/* eslint-disable no-console */
// `next` is a function that takes an 'action' and sends it through to the 'reducers'.
const middleware = (next) => (action) => {
let result;
if (!!console.time) {
console.time(action.type);
result = next(action);
console.timeEnd(action.type);
} else {
result = next(action);
}
return result;
};
return middleware;
};
}
export {
perfMiddleware,
};