Skip to content

This is an example app using webpack-rails-react with the --router flag passed on generartion

Notifications You must be signed in to change notification settings

cottonwoodcoding/webpack-rails-react-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webpack-rails-react-router

This example app was built using webpack-rails-react with the --router flag passed on generation. This is a simple Todo List App to demonstrate extracting your client to a React application using react-router.

Running Sample App

  1. git clone
  2. npm install && bundle install
  3. bundle exec rake db:create db:migrate
  4. foreman start

Steps taken

  1. Create a new rails app
rails new todo_app --skip-turbolinks
  1. add webpack-rails-react to your Gemfile
gem 'webpack-rails-react'
  1. create and migrate the database
  2. generate the app with react-router
bundle exec rails g webpack_rails_react:install --router
  1. enter y to npm install
  2. enter y to bundle install
  3. generate a controller
rails g controller home index --no-helper --no-assets
  1. change your routes file to root to your new controller and hand off all routes to react-router
root 'home#index'
get '*unmatched_route', to: 'home#index'

*unmatched _route must be the last line of the routes file 9. Create a NoMatch component and add to your client side routes.

<Route path="*" status={404} component={NoMatch}/>
  1. app/views/home/index.html.erb add <div id="app"></div>
  2. You will find the react app in webpack/

About

This is an example app using webpack-rails-react with the --router flag passed on generartion

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published