Skip to content

Commit 490a002

Browse files
theJiantimdorr
authored andcommitted
Remove subkey (reduxjs#945)
* Add test for custom store key to connect * Remove subkey
1 parent 9abd0c5 commit 490a002

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

src/components/Provider.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function warnAboutReceivingStore() {
1919
)
2020
}
2121

22-
export function createProvider(storeKey = 'store', subKey) {
23-
const subscriptionKey = subKey || `${storeKey}Subscription`
22+
export function createProvider(storeKey = 'store') {
23+
const subscriptionKey = `${storeKey}Subscription`
2424

2525
class Provider extends Component {
2626
getChildContext() {

src/connect/selectorFactory.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import verifySubselectors from './verifySubselectors'
2-
2+
33
export function impureFinalPropsSelectorFactory(
44
mapStateToProps,
55
mapDispatchToProps,
@@ -64,7 +64,7 @@ export function pureFinalPropsSelectorFactory(
6464
const nextStateProps = mapStateToProps(state, ownProps)
6565
const statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps)
6666
stateProps = nextStateProps
67-
67+
6868
if (statePropsChanged)
6969
mergedProps = mergeProps(stateProps, dispatchProps, ownProps)
7070

test/components/connect.spec.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types'
66
import ReactDOM from 'react-dom'
77
import TestRenderer from 'react-test-renderer'
88
import { createStore } from 'redux'
9-
import { connect } from '../../src/index'
9+
import { connect, createProvider } from '../../src/index'
1010

1111
describe('React', () => {
1212
describe('connect', () => {
@@ -2324,5 +2324,27 @@ describe('React', () => {
23242324
expect(mapStateToPropsC).toHaveBeenCalledTimes(2)
23252325
expect(mapStateToPropsD).toHaveBeenCalledTimes(2)
23262326
})
2327+
2328+
it('should receive the store in the context using a custom store key', () => {
2329+
const store = createStore(() => ({}))
2330+
const CustomProvider = createProvider('customStoreKey')
2331+
const connectOptions = { storeKey: 'customStoreKey' }
2332+
2333+
@connect(undefined, undefined, undefined, connectOptions)
2334+
class Container extends Component {
2335+
render() {
2336+
return <Passthrough {...this.props} />
2337+
}
2338+
}
2339+
2340+
const testRenderer = TestRenderer.create(
2341+
<CustomProvider store={store}>
2342+
<Container />
2343+
</CustomProvider>
2344+
)
2345+
2346+
const container = testRenderer.root.findByType(Container)
2347+
expect(container.instance.store).toBe(store)
2348+
})
23272349
})
23282350
})

0 commit comments

Comments
 (0)