LoginSignup
6
5

More than 5 years have passed since last update.

RailsでReact開発環境を作る。

Posted at

備忘録。


Gem

  • react-rails
  • browserify-rails

npm_modules

  • browserify
  • browserify_incremental
  • babelify
  • babel-preset-es2015
  • babel-preset-react
  • babel-preset-stage-2
  • react
  • react-dom
  • react-redux
  • redux
  • redux-thunk

以上をGemfile及びpackage.jsonでインストールする。

.babelrc

.babelrcに以下を記述

{
    "presets": ["ec2015", "stage-2", "react"]
}

config/application.rb

config.browserify_rails.commandline_options = '-t babelify --extension=.jsx'

続いてreactをインストールする。
rails g react:install

components.js

window.React = require('react');
window.ReactDOM = require('react-dom');
window.Hello = require('./components/hello');  //Reactコンポーネント

こうするとnpmから入れたreactをヘルパーでよびだせる。


参考URL
http://qiita.com/suzan2go/items/24ef3320e04b8a84597f
http://qiita.com/imaimiami/items/f5362099533aefcdd2b4
http://qiita.com/kozo002/items/a276569e85395fce801e

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5