File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed
Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -64,8 +64,4 @@ export function connect(mapStateToProps, actions) {
6464export function Provider ( props ) {
6565 this . getChildContext = ( ) => ( { store : props . store } ) ;
6666}
67- // Provider.prototype.getChildContext = function () {
68- // return { store: this.props.store };
69- // };
7067Provider . prototype . render = props => props . children && props . children [ 0 ] || props . children ;
71- // Provider.prototype.render = props => Array.isArray(props.children) ? props.children[0] : props.children;
Original file line number Diff line number Diff line change @@ -25,11 +25,11 @@ export function connect(mapStateToProps, actions) {
2525 return Child => {
2626 function Wrapper ( props , context ) {
2727 Component . call ( this , props , context ) ;
28- let { store } = context ;
28+ const store = context . store ;
2929 let state = mapStateToProps ( store ? store . getState ( ) : { } , props ) ;
30- let boundActions = actions ? mapActions ( actions , store ) : { store } ;
30+ const boundActions = actions ? mapActions ( actions , store ) : { store } ;
3131 let update = ( ) => {
32- let mapped = mapStateToProps ( store ? store . getState ( ) : { } , this . props ) ;
32+ let mapped = mapStateToProps ( store ? store . getState ( ) : { } , props ) ;
3333 for ( let i in mapped ) if ( mapped [ i ] !== state [ i ] ) {
3434 state = mapped ;
3535 return this . forceUpdate ( ) ;
@@ -39,7 +39,10 @@ export function connect(mapStateToProps, actions) {
3939 return this . forceUpdate ( ) ;
4040 }
4141 } ;
42- this . componentWillReceiveProps = update ;
42+ this . componentWillReceiveProps = p => {
43+ props = p ;
44+ update ( ) ;
45+ } ;
4346 this . componentDidMount = ( ) => {
4447 store . subscribe ( update ) ;
4548 } ;
Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ describe('<Provider>', () => {
240240 // await sleep(100);
241241
242242 expect ( mapStateToProps ) . toHaveBeenCalledTimes ( 1 ) ;
243- expect ( mapStateToProps ) . toHaveBeenCalledWith ( { } , { } ) ;
243+ expect ( mapStateToProps ) . toHaveBeenCalledWith ( { } , { a : 'b' } ) ;
244244 // outer props were changed
245245 expect ( Child ) . toHaveBeenCalledWith (
246246 { mappings : 2 , a : 'b' , store } ,
You can’t perform that action at this time.
0 commit comments