File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { Component , PropTypes } from 'react' ;
2
2
import mapValues from 'lodash/object/mapValues' ;
3
+ import shallowEqual from './utils/shallowEqual' ;
3
4
4
5
export default class Injector extends Component {
5
6
static contextTypes = {
@@ -17,6 +18,15 @@ export default class Injector extends Component {
17
18
actions : { }
18
19
} ;
19
20
21
+ shouldComponentUpdate ( nextProps , nextState ) {
22
+ return this . hasChanged ( this . state . atom , nextState . atom ) ||
23
+ ! shallowEqual ( this . props . actions , nextProps . actions ) ;
24
+ }
25
+
26
+ hasChanged ( atom , prevAtom ) {
27
+ return atom !== prevAtom ;
28
+ }
29
+
20
30
constructor ( props , context ) {
21
31
super ( props , context ) ;
22
32
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import Injector from '../Injector' ;
3
3
import getDisplayName from '../utils/getDisplayName' ;
4
+ import shallowEqualScalar from '../utils/shallowEqualScalar' ;
4
5
5
6
function mergeAll ( { props, state, actions } ) {
6
7
return { ...props , ...state , ...actions } ;
@@ -13,6 +14,10 @@ export default function inject(
13
14
return DecoratedComponent => class InjectorDecorator {
14
15
static displayName = `Injector(${ getDisplayName ( DecoratedComponent ) } )` ;
15
16
17
+ shouldComponentUpdate ( nextProps ) {
18
+ return ! shallowEqualScalar ( this . props , nextProps ) ;
19
+ }
20
+
16
21
constructor ( ) {
17
22
this . renderChild = this . renderChild . bind ( this ) ;
18
23
}
You can’t perform that action at this time.
0 commit comments