繁体   English   中英

什么时候可以在react / react中使用reactDOM /如何使某些东西出现在屏幕上而不是在consoke中?

[英]When can you use reactDOM in react/how can i make something appear on screen rather than in consoke?

我是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')
);

但是它会说unresolved variable or type 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');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM