React Redux Rails 1 / 5 ãç°å¢æ§ç¯ã
ã¯ããã«
Riot.js Redux Railsã·ãªã¼ãºã§ä½ã£ãTodoã¢ããªã®Riot.jsé¨åãReactã使ã£ã¦æ¸ããã
Riot.js Redux Railsã§ä½ã£ãTodoã¢ããªã¨å ¨ãåããã®ãä½æããã®ã§ã³ã¼ãã大åéãªã£ã¦ãã(Riot.jsé¨åãReactã«ããã ã)ããä»åã®ä¸é£ã®è¨äºã ãèªãã§ãåºæ¥ãããã«çç¥ã¯ããªã(ã»ã¼ã³ããã ã)ã
ç°å¢æ§ç¯
- React Redux Rails 1 / 5 ãç°å¢æ§ç¯ã
Todo Appã®ä½æ
- React Redux Rails 2 / 5 ãTodoãªã¹ãã表示ããã
- React Redux Rails 3 / 5 ãæ°ããªTodoã追å åºæ¥ãããã«ããã
- React Redux Rails 4 / 5 ãå®äºããTodoããã§ãã¯åºæ¥ãããã«ããã
- React Redux Rails 5 / 5 ããã§ãã¯ãã¦ããã¿ã¹ã¯ãåé¤åºæ¥ãããã«ããã
æçµçã«å®æããTodo App
https://github.com/atfeo/React_Redux_Rails
åè
ç°å¢æ§ç¯
ã¿ã¼ããã«
$ rails new react_redux_rails $ cd react_redux_rails $ mkdir client $ cd client
clientãã£ã¬ã¯ããª
Package.json
$ npm init -y
ããã«ããpackage.jsonãä½æãããã®ã§
{ "private": "true", "scripts": { "webpack-watch": "webpack -w" } }
ã®ããã«æ¸ãæããã åã³ã¿ã¼ããã«ã§
$ npm install --save-dev webpack babel-core babel-loader babel-preset-react babel-preset-es2015
åãã
$ npm install --save react react-dom redux react-redux redux-thunk
webpackã®è¨å®
webpack.config.jsãä½æã
// ./client/webpack.config.js module.exports = { entry: { app: './src/index.jsx', }, output: { path: '../app/assets/javascripts/webpack', filename: 'bundle.js', }, module: { loaders: [ { test: /\.(js|jsx)$/, loader: "babel", exclude: /node_modules/, query: { presets: ["es2015", "react"], } }, ] }, };
ããã¦
$ cd ..
ã§ãã¢ããªã±ã¼ã·ã§ã³ã®ã«ã¼ãã«æ»ã£ã¦ãã
Gemfile
Gemfileã«
# Gemfile gem 'foreman'
ã追å ã
$ bundle install
Procfile
ã¢ããªã±ã¼ã·ã§ã³ã®ã«ã¼ããã£ã¬ã¯ããªã«Procfileãä½æ
rails: rails s webpack: npm --prefix client run webpack-watch
ç°å¢æ§ç¯çµããã
次åããTodoã¢ããªã®ä½æã
React Redux Rails 2 / 5ã«ç¶ã