Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add redux-devtools-extension trace feature in development mode if available. #3781

Merged
merged 20 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions docs/CustomApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,29 @@ export default ({
);
};
const sagaMiddleware = createSagaMiddleware();

const typedWindow = window;
WiXSL marked this conversation as resolved.
Show resolved Hide resolved

const composeEnhancers =
(process.env.NODE_ENV === 'development' &&
typeof typedWindow !== 'undefined' &&
typedWindow.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ &&
typedWindow.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
trace: true,
traceLimit: 25,
})) ||
compose;

const store = createStore(
resettableAppReducer,
{ /* set your initial state here */ },
compose(
composeEnhancers(
applyMiddleware(
sagaMiddleware,
routerMiddleware(history),
// add your own middlewares here
),
typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__
? window.__REDUX_DEVTOOLS_EXTENSION__()
: f => f
// add your own enhancers here
)
),
);
sagaMiddleware.run(saga);
return store;
Expand Down
20 changes: 13 additions & 7 deletions packages/ra-core/src/createAdminStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { adminSaga } from './sideEffect';
import { CLEAR_STATE } from './actions/clearActions';

interface Window {
__REDUX_DEVTOOLS_EXTENSION__?: () => () => void;
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: (traceOptions: object) => Function;
}

export type InitialState = object | (() => object);
Expand Down Expand Up @@ -61,15 +61,21 @@ export default ({
const sagaMiddleware = createSagaMiddleware();
const typedWindow = window as Window;

const composeEnhancers =
(process.env.NODE_ENV === 'development' &&
typeof typedWindow !== 'undefined' &&
typedWindow.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ &&
typedWindow.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
trace: true,
traceLimit: 25,
})) ||
compose;
WiXSL marked this conversation as resolved.
Show resolved Hide resolved

const store = createStore(
resettableAppReducer,
typeof initialState === 'function' ? initialState() : initialState,
compose(
applyMiddleware(sagaMiddleware, routerMiddleware(history)),
typeof typedWindow !== 'undefined' &&
typedWindow.__REDUX_DEVTOOLS_EXTENSION__
? typedWindow.__REDUX_DEVTOOLS_EXTENSION__()
: f => f
composeEnhancers(
applyMiddleware(sagaMiddleware, routerMiddleware(history))
)
);
sagaMiddleware.run(saga);
Expand Down