From 4bcfeddfa02b83bcfb4ba76319aa9e7b05fa9cbc Mon Sep 17 00:00:00 2001 From: "C. T. Lin" Date: Sat, 15 Aug 2015 11:12:17 +0800 Subject: [PATCH] fix `process is not defined` in react-native --- src/utils/combineReducers.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/utils/combineReducers.js b/src/utils/combineReducers.js index 8ba298991a..1a9fca8973 100644 --- a/src/utils/combineReducers.js +++ b/src/utils/combineReducers.js @@ -105,9 +105,20 @@ export default function combineReducers(reducers) { return newState; }); - if (process.env.NODE_ENV !== 'production' && !stateShapeVerified) { - verifyStateShape(state, finalState); - stateShapeVerified = true; + if (( + // Node-like CommonJS environments (Browserify, Webpack) + typeof process !== 'undefined' && + typeof process.env !== 'undefined' && + process.env.NODE_ENV !== 'production' + ) || + // React Native + typeof __DEV__ !== 'undefined' && + __DEV__ //eslint-disable-line no-undef + ) { + if (!stateShapeVerified) { + verifyStateShape(state, finalState); + stateShapeVerified = true; + } } return finalState;