汇总在运用react遇到的一些问题以及解决方案。
1. Module not found: Can't resolve 'react-dom/lib/ReactPerf'
解决方法: React 16中不再支持react-addon-perf,新方案 https://reactjs.org/docs/optimizing-performance.html#profiling-components-with-the-chrome-performance-tab
2. 'react-router' does not contain an export named 'browserHistory'
解决方法:react-router v4中不导入browserHistory, 可以使用v3版本,npm install react-router@3,
参见:https://github.com/ReactTraining/react-router/issues/5263
3. Module not found: Can't resolve 'redux' in ...
解决方法: npm install --save redux
4. TypeError: Cannot read property 'string' of undefined
解决方法:
import {PropTypes} from 'prop-types';
static proptypes={
***:PropTypes.string
};
5. create-react-app **出现“Unexpected end of JSON input while parsing near '..."shasum":"0c48875896f'”
解决方法:npm cache clean --force