我正在使用Webpack和热模块重新加载.我还使用chrome扩展React Developer Tools在开发时检查反应树.当我检查页面并查看组件树时,我希望看到实际组件的名称,但是,对于名称显示为Proxy Component的
我可以让你知道关于我的Webpack的更多细节,但我正在努力甚至谷歌正确解决这个问题.
以下是我用于webpack的工具:
"webpack": "^1.9.6", "webpack-dev-middleware": "^1.2.0", "webpack-dev-server": "^1.14.1", "webpack-hot-middleware": "^2.0.0"
webpack.config.js
var path = require('path'); var webpack = require('webpack'); module.exports = { devtool: 'eval', entry: [ 'webpack-hot-middleware/client', './client/index' ], output: { path: path.join(__dirname, 'static'), filename: 'bundle.js', publicPath: '/static/' }, plugins: [ new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() ], module: { loaders: [ { test: /\.json$/, loader: 'json' }, { test: /\.js$/, loader: 'babel-loader', include: path.join(__dirname, 'client'), query: { plugins: ['transform-runtime'], presets: ['es2015', 'stage-0', 'react', 'react-hmre'] } }, { test: /\.scss$/, loaders: ['style', 'css', 'sass'] } ] } };您是否尝试过分配displayName属性?
export const Navbar = (props) => { let title = null; let menu = null; return ( <header className={style.navbar}> <Grid> <Row> <Col xs={12} sm={12} md={12} lg={12}> {title} {menu} </Col> </Row> </Grid> </header> ); }; Navbar.displayName = 'Navbar'; // LIKE THIS Navbar.propTypes = { title: PropTypes.string, items: PropTypes.arrayOf(PropTypes.node), };