From a828d1fd9279b84f55f34b0c3cf70bacb494085f Mon Sep 17 00:00:00 2001 From: Ray Lee Date: Thu, 14 Oct 2021 20:27:12 -0400 Subject: [PATCH] Allow Redux DevTools browser extension to be used. (#13) --- README.md | 4 ++++ src/store.ts | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4aab64eed..0689f9fd4 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,10 @@ There are end-to-end tests that run on Nightwatch. This selenium-based test runn To set up credentials and run the tests, check out the [README](/tests/README.md) in `/tests/. +## Debugging + +The [Redux DevTools browser extension](https://github.com/reduxjs/redux-devtools/tree/main/extension) may be used to easily inspect app states and state transitions. + ## License ``` diff --git a/src/store.ts b/src/store.ts index d1e60c036..a26d96c0b 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1,4 +1,5 @@ import { + compose, createStore, combineReducers, applyMiddleware, @@ -14,8 +15,15 @@ const reducers: Reducer = combineReducers({ catalog: catalogReducers, }); +const composeEnhancers = + window["__REDUX_DEVTOOLS_EXTENSION_COMPOSE__"] || compose; + /** Build a redux store with reducers specific to the admin interface as well as reducers from opds-web-client. */ export default function buildStore(initialState?: State): Store { - return createStore(reducers, initialState, applyMiddleware(thunk)); + return createStore( + reducers, + initialState, + composeEnhancers(applyMiddleware(thunk)) + ); }