A simple setup for putting react into your rails
- Copy assets into your rails project
- Install modules
npm install - Add bundle tag
- Go!
foreman start -f Procfile.dev
Drop this into your main application layout
<%= javascript_bundle_tag 'main' %>Export component in app/assets/javascripts/components/index.js
// app/assets/javascripts/components/index.js
export MyComponent from './MyComponent'Use the component helper to render a React component into a view:
component(String component_name, Hash props)
<%= component('MyComponent', {}) %>The javascript bundle will be compiled during assets:precompile