11const { Component, PropTypes, Children } = require ( 'react' )
22const storeShape = require ( '../utils/storeShape' )
33
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 */
825 }
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- )
1826}
1927
2028class Provider extends Component {
@@ -27,19 +35,21 @@ class Provider extends Component {
2735 this . store = props . store
2836 }
2937
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 ) {
3146 const { store } = this
3247 const { store : nextStore } = nextProps
3348
3449 if ( store !== nextStore ) {
3550 warnAboutReceivingStore ( )
3651 }
3752 }
38-
39- render ( ) {
40- let { children } = this . props
41- return Children . only ( children )
42- }
4353}
4454
4555Provider . propTypes = {
0 commit comments