Skip to content

Commit e82ef7d

Browse files
committed
Throw if there are more than one instrument enhancer included
1 parent a3d0538 commit e82ef7d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/instrument.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ export default function instrument(monitorReducer = () => null) {
343343
}
344344

345345
const liftedStore = createStore(liftReducer(reducer), undefined, enhancer);
346+
if (liftedStore.liftedStore) {
347+
throw new Error('DevTools instrument shouldn\'t be included more than once. ' +
348+
'Check your store configuration.');
349+
}
346350
return unliftStore(liftedStore, liftReducer);
347351
};
348352
}

test/instrument.spec.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import expect, { spyOn } from 'expect';
2-
import { createStore } from 'redux';
2+
import { createStore, compose } from 'redux';
33
import instrument, { ActionCreators } from '../src/instrument';
44

55
function counter(state = 0, action) {
@@ -328,4 +328,9 @@ describe('instrument', () => {
328328
instrument()(createStore)()
329329
).toThrow('Expected the nextReducer to be a function.');
330330
});
331+
it('throws if there are more than one instrument enhancer included', () => {
332+
expect(() => {
333+
store = createStore(counter, undefined, compose(instrument(), instrument()));
334+
}).toThrow('DevTools instrument shouldn\'t be included more than once. Check your store configuration.');
335+
});
331336
});

0 commit comments

Comments
 (0)