我试着遵循“掌握反应书”,下面有一个示例,其代码如下
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Hello React</title>
<script src="https://<fb shortened url>/react-with-addons-0.14.0.js"></script>
<script src="https://<fb shortened url>/react-dom-0.14.0.js"></script>
<script src="http://<fb shortened url>/JSXTransformer-0.13.1.js"></script>
</head>
<body>
<div id="view" />
<script>
var HelloReact = React.createClass({
render: function () {
return <h1 > Hello React < /h1>
}
});
ReactDOM.render( < HelloReact / > , document.body);
</script>
</body>
</html>然而,上述情况似乎不起作用。我不会在文档体中获得HelloReact。
我完全是新的反应(也是JSX转换等)。任何帮助都将不胜感激。
我在Chrome中遇到的错误是
Uncaught Error: Invariant Violation: ReactDOM.render(): Invalid component element. Instead of passing an element string, make sure to instantiate it by passing it to React.createElement.注意:fb shortened url是fb.me,Stackoverflow抱怨使用短程序,
发布于 2016-04-21 15:54:52
正如许多人已经注意到的那样,ReactiveandReactiveNativeNative已经改变了各自的构建系统,以利用Babel。这取代了我们在Facebook上编写的源代码转换工具JSTransform。
https://facebook.github.io/react/blog/2015/06/12/deprecating-jstransform-and-react-tools.html
使用babel将JSX语法转换为JS,并在文件中使用JS
https://stackoverflow.com/questions/36774686
复制相似问题