File tree Expand file tree Collapse file tree 4 files changed +11
-16
lines changed Expand file tree Collapse file tree 4 files changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -151,11 +151,11 @@ import Counter from './Counter';
151151
152152export default class CounterContainer {
153153 render () {
154- // stores can be a single store or an array.
155- // actions can only be a string -> function map.
154+ // stores must be an array.
155+ // actions must be a string -> function map.
156156 // props passed to children will combine these actions and state.
157157 return (
158- < Container stores= {counterStore}
158+ < Container stores= {[ counterStore] }
159159 actions= {{ increment, decrement }}>
160160 {props => < Counter {... props} / > }
161161 < / Container>
@@ -177,7 +177,7 @@ import counterStore from './stores/counterStore';
177177
178178@container ({
179179 actions: { increment, decrement },
180- stores: counterStore
180+ stores: [ counterStore]
181181})
182182export default class Counter {
183183 static propTypes = {
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import Counter from './Counter';
88export default class CounterApp extends Component {
99 render ( ) {
1010 return (
11- < Container stores = { counterStore } actions = { { increment, decrement } } >
11+ < Container stores = { [ counterStore ] } actions = { { increment, decrement } } >
1212 { props => < Counter { ...props } /> }
1313 </ Container >
1414 ) ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { container } from 'redux';
33import { todoStore } from './stores/index' ;
44
55@container ( {
6- stores : todoStore
6+ stores : [ todoStore ]
77} )
88export default class Body {
99 static propTypes = {
Original file line number Diff line number Diff line change @@ -11,9 +11,7 @@ export default class ReduxContainer extends Component {
1111 children : PropTypes . func . isRequired ,
1212 actions : PropTypes . object . isRequired ,
1313 stores : PropTypes . oneOfType ( [
14- PropTypes . func . isRequired ,
15- PropTypes . arrayOf ( PropTypes . func . isRequired ) . isRequired ,
16- PropTypes . object . isRequired
14+ PropTypes . arrayOf ( PropTypes . func . isRequired ) . isRequired
1715 ] ) . isRequired
1816 }
1917
@@ -43,13 +41,10 @@ export default class ReduxContainer extends Component {
4341 this . unsubscribe ( ) ;
4442 }
4543
46- let stores = props . stores ;
47- let mapState = identity ;
48- if ( typeof props . stores === 'function' ) {
49- const store = props . stores ;
50- stores = [ store ] ;
51- mapState = state => state [ store . name ] ;
52- }
44+ const { stores } = props ;
45+ const mapState = ( stores . length === 1 ) ?
46+ state => state [ stores [ 0 ] . name ] :
47+ identity ;
5348
5449 this . mapState = mapState ;
5550 this . unsubscribe = observeStores ( stores , this . handleChange ) ;
You can’t perform that action at this time.
0 commit comments