# Require the gems listed in Gemfile, including any gems
# you’ve limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module RailsRedux
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
+ config.browserify_rails.commandline_options = '-t babelify'
end
end
[/bash]
app/assets/javascripts/myapp.js
[bash]
import React from “react”
import {createStore} from “redux”
import rootReducer from “./reducers/root”
import Root from “./components/Root”
class MyApp extends React.Component{
render(){
let store = createStore(rootReducer)
return (
)
}
}
export default MyApp
[/bash]
アプリケーションRoot
app/assets/javascripts/components/Root.js
[bash]
import React from “react”
import {Provider} from “react-redux”
import { BrowserRouter as Router, Route} from “react-router-dom”
import App from “./App”
import Top from “./Top”
import About from “./About”
import Contact from “./Contact”
import CCounter from “../containers/CCounter”
const Root = ({store}) => {
return (
}/>
)
}
export default Root
[/bash]
アプリケーションのトップページ
app/assets/javascripts/components/App.js
[bash]
import React from “react”
import {NavLink} from “react-router-dom”
config/routes.rb
[bash]
Rails.application.routes.draw do
get ‘myapp/index’
get ‘myapp/*path’, to: ‘myapp#index’
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
[/bash]
デザイン調整
app/assets/stylesheets/myapp.scss
[bash]
// Place all the styles related to the first controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.
Leave a comment