React Js into Ruby On Rails application
Create New Application: $ rails new rails-react-webpacker $ cd rails-react-webpacker Add webpacker and react-rails to your Gemfile and run the installers $ bundle install $ rails webpacker:install $ rails webpacker:install:react $ rails generate react:install After the successful completion the of the above commands. You will have the directory structure like below image. All of our React components shall go to app/javascript/components/ directory. The content of app/javascript/packs/application.js is as following. console . log ( ' Hello World from Webpacker ' ) var componentRequireContext = require . context ( " components " , true ) var ReactRailsUJS = require ( " react_ujs " ) ReactRailsUJS . useContext (componentRequireContext) The line var componentRequireContext = require.context(“components”, true) makes the react components available to our rails app. Now ...