在我对react-server-example
(https://github.com/mhart/react-server-example)的改编中,我似乎无法使用JSX 。我已经做了一些更改(比如用Webpack替换Browserify等等),然而,在广泛浏览并安装babel-present-react
之后,我似乎无法弄清楚我为了运行应用而缺少的东西。
的package.json
{
"name": "react-server-example",
"version": "1.1.5",
...
"dependencies": {
"babel-preset-react": "^6.5.0",
"react": "^0.14.7",
"react-dom": "^0.14.7"
},
"devDependencies": {
"babel-cli": "^6.6.5",
"babelify": "^7.2.0",
"webpack": "^1.12.14"
}
}
webpack.config.js
module.exports = {
entry: "./entry.js",
output: {
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" },
{ test: /\.js$/, loader: "jsx-loader" },
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel",
query:
{
presets:['react']
}
}
]
}
};
.babelrc
{
"presets": ["es2015", "stage-0", "react"]
}
答案 0 :(得分:-1)
应该是:
render: function() {
return (
<Test name="wassuppp" />
);
}
您似乎错过了返回的开头(
。