mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-03-03 18:58:01 +03:00
Throw if there are more than one instrument enhancer included
This commit is contained in:
parent
a3d053880c
commit
e82ef7de59
|
@ -343,6 +343,10 @@ export default function instrument(monitorReducer = () => null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const liftedStore = createStore(liftReducer(reducer), undefined, enhancer);
|
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);
|
return unliftStore(liftedStore, liftReducer);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import expect, { spyOn } from 'expect';
|
import expect, { spyOn } from 'expect';
|
||||||
import { createStore } from 'redux';
|
import { createStore, compose } from 'redux';
|
||||||
import instrument, { ActionCreators } from '../src/instrument';
|
import instrument, { ActionCreators } from '../src/instrument';
|
||||||
|
|
||||||
function counter(state = 0, action) {
|
function counter(state = 0, action) {
|
||||||
|
@ -328,4 +328,9 @@ describe('instrument', () => {
|
||||||
instrument()(createStore)()
|
instrument()(createStore)()
|
||||||
).toThrow('Expected the nextReducer to be a function.');
|
).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.');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user