我是 ReactJS 和 Flux 的新手,正在尝试创建一个应用程序。 我的应用程序组件中有此代码。
var App = React.createClass({
handleClick1: function() {
AppActions.addItem('this is the first item');
},
handleClick2: function() {
AppActions.addItem('this is the second item');
},
handleClick3: function() {
AppActions.addItem('this is the third item');
},
render: function() {
return (
<div className="wrapper">
<button it="buttonOne" type="button" onClick={this.handleClick1}>I will display item 1!</button>
<button type="button" onClick={this.handleClick2}>I will display item 2!</button>
<button type="button" onClick={this.handleClick3}>I will display item 3!</button>
{/* <h3 onClick={this.handleClick}>Click this Title, then check console</h3> --> */}
<p> hello </p>
</div>
)
}
});
module.exports = App;
我想添加类似这样的代码:
ReactDOM.render(
<CommentBox />,
document.getElementById('wrapper')
);
但出现未解析的变量或类型ReactDOM
所以我想这个问题有两个部分。
1) 你怎么知道如何使用 ReactDOM 以及何时使用 2) 我怎样才能让某些东西出现在浏览器中,即我的 p
标签所在的位置,因为目前它只出现在控制台中
最佳答案
正如 0.14 的发行说明所说,它们现在是两个独立的包:https://facebook.github.io/react/blog/2015/10/07/react-v0.14.html
var React = require('react');
var ReactDOM = require('react-dom');
关于javascript - 你什么时候可以在react中使用reactDOM/我怎样才能让某些东西出现在屏幕上而不是consoke中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33433826/