Created
October 12, 2018 16:44
-
-
Save sbonami/398f44cf91680cbb39c8464fd6a90dd1 to your computer and use it in GitHub Desktop.
Redux Interaction tracking with React Profiling & Interaction APIs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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