Throw if there are more than one instrument enhancer included

This commit is contained in:
Zalmoxisus 2016-02-02 18:07:58 +02:00
parent a3d053880c
commit e82ef7de59
2 changed files with 10 additions and 1 deletions

View File

@ -343,6 +343,10 @@ export default function instrument(monitorReducer = () => null) {
}
const liftedStore = createStore(liftReducer(reducer), undefined, enhancer);
if (liftedStore.liftedStore) {
throw new Error('DevTools instrument shouldn\'t be included more than once. ' +
'Check your store configuration.');
}
return unliftStore(liftedStore, liftReducer);
};
}

View File

@ -1,5 +1,5 @@
import expect, { spyOn } from 'expect';
import { createStore } from 'redux';
import { createStore, compose } from 'redux';
import instrument, { ActionCreators } from '../src/instrument';
function counter(state = 0, action) {
@ -328,4 +328,9 @@ describe('instrument', () => {
instrument()(createStore)()
).toThrow('Expected the nextReducer to be a function.');
});
it('throws if there are more than one instrument enhancer included', () => {
expect(() => {
store = createStore(counter, undefined, compose(instrument(), instrument()));
}).toThrow('DevTools instrument shouldn\'t be included more than once. Check your store configuration.');
});
});