Help us understand the problem. What is going on with this article?

今からはじめるReact.js〜React ver0.14〜

More than 3 years have passed since last update.

前回→今からはじめるReact.js〜スタイルの適用〜

ReactDOM

0.14でReactDOMがReactから分離されました。
そのため、render()findDOMNode()はReactDOMのメソッドを使用しなければなりません。

さっそく、react-domをインストールします。

index.jsは以下のように、インポートの追加と、最後のReact.renderの箇所を書き換えます。

npm install react-dom --save

index.js
var React = require('react');
var ReactDOM = require('react-dom');//react-domをインポート
var Header = require('./views/header.jsx');
var Body = require('./views/body.jsx');
var Footer = require('./views/footer.jsx');

//classNameでcssを指定
var Index = React.createClass({
  render:function(){
    return (
      <div>
        <Header/>
        <div className="main">
          <Body/>
        </div>
        <Footer/>
      </div>
    );
  }
});

//React.renderをReactDOM.renderに変更。
ReactDOM.render(
  <Index />,
  document.getElementById('content')
);

0.13からバージョンアップした際の注意事項ですが、今まで
React.findDOMNode()
と書いていたところも、
ReactDOM.findDOMNode()
と書く必要があります。
で、そもそもgetDOMNode()は使わないでねと。

サンプルソース

https://github.com/kunitak/react-tutorial/tree/day4

次回→今からはじめるReact.js〜propsとstate、それからrefs〜

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away