1
1
const { Component, PropTypes, Children } = require ( 'react' )
2
2
const storeShape = require ( '../utils/storeShape' )
3
3
4
- let didWarnAboutReceivingStore = false
5
- function warnAboutReceivingStore ( ) {
6
- if ( didWarnAboutReceivingStore ) {
7
- return
4
+ if ( process . env . NODE_ENV !== 'production' ) {
5
+ let didWarnAboutReceivingStore = false
6
+ /* eslint-disable no-var */
7
+ var warnAboutReceivingStore = function ( ) {
8
+ /* eslint-enable no-var */
9
+ if ( didWarnAboutReceivingStore ) {
10
+ return
11
+ }
12
+ didWarnAboutReceivingStore = true
13
+
14
+ /* eslint-disable no-console */
15
+ if ( typeof console !== 'undefined' && typeof console . error === 'function' ) {
16
+ console . error (
17
+ '<Provider> does not support changing `store` on the fly. ' +
18
+ 'It is most likely that you see this error because you updated to ' +
19
+ 'Redux 2.x and React Redux 2.x which no longer hot reload reducers ' +
20
+ 'automatically. See https://github.com/rackt/react-redux/releases/' +
21
+ 'tag/v2.0.0 for the migration instructions.'
22
+ )
23
+ }
24
+ /* eslint-disable no-console */
8
25
}
9
-
10
- didWarnAboutReceivingStore = true
11
- console . error ( // eslint-disable-line no-console
12
- '<Provider> does not support changing `store` on the fly. ' +
13
- 'It is most likely that you see this error because you updated to ' +
14
- 'Redux 2.x and React Redux 2.x which no longer hot reload reducers ' +
15
- 'automatically. See https://github.com/rackt/react-redux/releases/' +
16
- 'tag/v2.0.0 for the migration instructions.'
17
- )
18
26
}
19
27
20
28
class Provider extends Component {
@@ -27,19 +35,21 @@ class Provider extends Component {
27
35
this . store = props . store
28
36
}
29
37
30
- componentWillReceiveProps ( nextProps ) {
38
+ render ( ) {
39
+ let { children } = this . props
40
+ return Children . only ( children )
41
+ }
42
+ }
43
+
44
+ if ( process . env . NODE_ENV !== 'production' ) {
45
+ Provider . prototype . componentWillReceiveProps = function ( nextProps ) {
31
46
const { store } = this
32
47
const { store : nextStore } = nextProps
33
48
34
49
if ( store !== nextStore ) {
35
50
warnAboutReceivingStore ( )
36
51
}
37
52
}
38
-
39
- render ( ) {
40
- let { children } = this . props
41
- return Children . only ( children )
42
- }
43
53
}
44
54
45
55
Provider . propTypes = {
0 commit comments