javascript - 你什么时候可以在react中使用reactDOM/我怎样才能让某些东西出现在屏幕上而不是consoke中?

标签 javascript reactjs flux

我是 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/

相关文章:

javascript - 任何用于 JavaScript 人脸识别的库?

javascript - 在 Create-React-App 中输入具有解构赋值参数的函数时出现意外标记

javascript - Axios Post 登录请求显示待处理状态?

reactjs-flux - 通量变化中的emitChange、addChangeListener和removeChangeListener的要点是什么

javascript - 在 sinon 中使用异步回调 stub 方法

javascript - 尽管在 Controller 中使用数组语法,AngularJS 代码并未正确缩小

javascript - typescript:如何从 2 个不同的对象集中获取具有相同属性值但不同键的对象

reactjs - 在 redux 存储中存储类的函数和实例可以吗?

reactjs - react +通量: best practice for calling an action after another action?

javascript - 为什么店里没有看到回流 Action ?