Skip to content

Instantly share code, notes, and snippets.

@alegoritma
Created April 25, 2022 06:14
Show Gist options
  • Select an option

  • Save alegoritma/042e731e1f3870e9c1956bd3d1c125f4 to your computer and use it in GitHub Desktop.

Select an option

Save alegoritma/042e731e1f3870e9c1956bd3d1c125f4 to your computer and use it in GitHub Desktop.
With this middleware you can measure timings on performance tab in the browser's devTools
const userTiming = () => (next) => (action) => {
if (performance.mark === undefined) return next(action);
performance.mark(`${action.type}_start`);
const result = next(action);
performance.mark(`${action.type}_end`);
performance.measure(
`${action.type}`,
`${action.type}_start`,
`${action.type}_end`,
);
return result;
}
const store = configureStore({
reducer: rootReducer,
devTools: true,
middleware: (getDefaultMiddleware) => [...getDefaultMiddleware(), userTiming]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment