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';
151
151
152
152
export default class CounterContainer {
153
153
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.
156
156
// props passed to children will combine these actions and state.
157
157
return (
158
- < Container stores= {counterStore}
158
+ < Container stores= {[ counterStore] }
159
159
actions= {{ increment, decrement }}>
160
160
{props => < Counter {... props} / > }
161
161
< / Container>
@@ -177,7 +177,7 @@ import counterStore from './stores/counterStore';
177
177
178
178
@container ({
179
179
actions: { increment, decrement },
180
- stores: counterStore
180
+ stores: [ counterStore]
181
181
})
182
182
export default class Counter {
183
183
static propTypes = {
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import Counter from './Counter';
8
8
export default class CounterApp extends Component {
9
9
render ( ) {
10
10
return (
11
- < Container stores = { counterStore } actions = { { increment, decrement } } >
11
+ < Container stores = { [ counterStore ] } actions = { { increment, decrement } } >
12
12
{ props => < Counter { ...props } /> }
13
13
</ Container >
14
14
) ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { container } from 'redux';
3
3
import { todoStore } from './stores/index' ;
4
4
5
5
@container ( {
6
- stores : todoStore
6
+ stores : [ todoStore ]
7
7
} )
8
8
export default class Body {
9
9
static propTypes = {
Original file line number Diff line number Diff line change @@ -11,9 +11,7 @@ export default class ReduxContainer extends Component {
11
11
children : PropTypes . func . isRequired ,
12
12
actions : PropTypes . object . isRequired ,
13
13
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
17
15
] ) . isRequired
18
16
}
19
17
@@ -43,13 +41,10 @@ export default class ReduxContainer extends Component {
43
41
this . unsubscribe ( ) ;
44
42
}
45
43
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 ;
53
48
54
49
this . mapState = mapState ;
55
50
this . unsubscribe = observeStores ( stores , this . handleChange ) ;
You can’t perform that action at this time.
0 commit comments