https://github.com/ripeworks/react-rails-simple
A simple setup for putting react into your rails
https://github.com/ripeworks/react-rails-simple
Last synced: 6 months ago
JSON representation
A simple setup for putting react into your rails
- Host: GitHub
- URL: https://github.com/ripeworks/react-rails-simple
- Owner: ripeworks
- Created: 2016-07-27T14:18:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-12T16:13:01.000Z (over 9 years ago)
- Last Synced: 2025-02-05T18:02:58.276Z (about 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-rails-simple
A simple setup for putting react into your rails
## Getting Started
1. Copy assets into your rails project
2. Install modules `npm install`
3. Add bundle tag
3. Go! `foreman start -f Procfile.dev`
## Adding the javascript bundle
Drop this into your main application layout
```erb
<%= javascript_bundle_tag 'main' %>
```
## Using components in rails views
Export component in `app/assets/javascripts/components/index.js`
```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)`
```erb
<%= component('MyComponent', {}) %>
```
## Production
The javascript bundle will be compiled during `assets:precompile`