Skip to content

Instantly share code, notes, and snippets.

@sbonami
Created October 12, 2018 16:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbonami/398f44cf91680cbb39c8464fd6a90dd1 to your computer and use it in GitHub Desktop.
Save sbonami/398f44cf91680cbb39c8464fd6a90dd1 to your computer and use it in GitHub Desktop.
Redux Interaction tracking with React Profiling & Interaction APIs
import { createStore, combineReducers, applyMiddleware } from 'redux';
import reactProfilerMiddleware from './react-profiler-redux';
const todoApp = combineReducers(reducers)
const store = createStore(
todoApp,
// applyMiddleware() tells createStore() how to handle middleware
applyMiddleware(reactProfilerMiddleware)
)
import { unstable_trace as trace } from 'schedule/tracing';
const reactProfilerMiddleware = store => next => action => {
const { type } = action;
return trace(`[redux] ${type}`, performance.now(), () => next(action));
}
export default reactProfilerMiddleware;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment