React Track
Demonstration of Webpack and React support in Rails 5.1 using the webpacker gem.
- The index route demonstrates a React component being rendered using data from a rails controller.
- The about route is a normal ERB route.
- The talks route uses standard ERB, and then a React component below it which receives its props from the talks controller.
In this way, you can introduce React only on specific pages.
Prerequisites
- Yarn must be installed
Try it out:
- Install bundler dependencies:
bundle
- Install javascript dependencies:
yarn
- Build database:
rails db:migrate
- Load sample data:
rake sample
- Load webpack dev server and rails together
foreman start
- View the webpage at http://localhost:5000
Demo:
You can see a demo here.