@@ -5,7 +5,7 @@ import { hasHooks } from './utils'
5
5
export let isInsideFunctionComponent = false
6
6
const COMPONENT = Symbol ( 'owner component' )
7
7
8
- export default function view ( Comp ) {
8
+ export default function view ( Comp ) {
9
9
const isStatelessComp = ! ( Comp . prototype && Comp . prototype . isReactComponent )
10
10
11
11
let ReactiveComp
@@ -47,7 +47,7 @@ export default function view(Comp) {
47
47
// a HOC which overwrites render, shouldComponentUpdate and componentWillUnmount
48
48
// it decides when to run the new reactive methods and when to proxy to the original methods
49
49
class ReactiveClassComp extends BaseComp {
50
- constructor ( props , context ) {
50
+ constructor ( props , context ) {
51
51
super ( props , context )
52
52
53
53
this . state = this . state || { }
@@ -60,12 +60,14 @@ export default function view(Comp) {
60
60
} )
61
61
}
62
62
63
- render ( ) {
64
- return isStatelessComp ? Comp ( this . props , this . context ) : super . render ( )
63
+ render ( ) {
64
+ return isStatelessComp
65
+ ? Comp ( this . props , this . context )
66
+ : super . render ( )
65
67
}
66
68
67
69
// react should trigger updates on prop changes, while easyState handles store changes
68
- shouldComponentUpdate ( nextProps , nextState ) {
70
+ shouldComponentUpdate ( nextProps , nextState ) {
69
71
const { props, state } = this
70
72
71
73
// respect the case when the user defines a shouldComponentUpdate
@@ -88,7 +90,7 @@ export default function view(Comp) {
88
90
}
89
91
90
92
// add a custom deriveStoresFromProps lifecyle method
91
- static getDerivedStateFromProps ( props , state ) {
93
+ static getDerivedStateFromProps ( props , state ) {
92
94
if ( super . deriveStoresFromProps ) {
93
95
// inject all local stores and let the user mutate them directly
94
96
const stores = mapStateToStores ( state )
@@ -101,7 +103,7 @@ export default function view(Comp) {
101
103
return null
102
104
}
103
105
104
- componentWillUnmount ( ) {
106
+ componentWillUnmount ( ) {
105
107
// call user defined componentWillUnmount
106
108
if ( super . componentWillUnmount ) {
107
109
super . componentWillUnmount ( )
@@ -126,7 +128,7 @@ export default function view(Comp) {
126
128
return ReactiveComp
127
129
}
128
130
129
- function mapStateToStores ( state ) {
131
+ function mapStateToStores ( state ) {
130
132
// find store properties and map them to their none observable raw value
131
133
// to do not trigger none static this.setState calls
132
134
// from the static getDerivedStateFromProps lifecycle method
0 commit comments