Skip to content

Instantly share code, notes, and snippets.

@andy-polhill
Created January 13, 2016 17:32
Show Gist options
  • Save andy-polhill/a9a256b7e09bb77f2a00 to your computer and use it in GitHub Desktop.
Save andy-polhill/a9a256b7e09bb77f2a00 to your computer and use it in GitHub Desktop.
React Perf Redux Middleware sketch
const whitelist = ['SEARCH_CHANGE_TEXT'];
const perfMiddleware = () => next => action => {
let result;
if (whitelist.includes(action.type)) {
console.group(action.type);
Perf.start();
result = next(action);
Perf.stop();
Perf.printWasted(Perf.getLastMeasurements());
console.groupEnd();
} else {
result = next(action);
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment