File tree 1 file changed +20
-4
lines changed
1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -56,13 +56,24 @@ https://github.com/reactjs/React-Rails/wiki
56
56
57
57
[ Webpacker] ( https://github.com/rails/webpacker ) integrates modern JS tooling with Rails.
58
58
59
- Add ` webpacker ` and ` react-rails ` to your gemfile and run the installers:
59
+ Create a new Rails app:
60
+ ```
61
+ $ rails new my-app --webpack=react
62
+ $ cd my-app
63
+ ```
64
+
65
+ Add ` webpacker ` and ` react-rails ` to your gemfile
66
+ ```
67
+ gem 'webpacker'
68
+ gem 'react-rails'
69
+ ```
60
70
71
+ Now run the installers:
61
72
```
62
73
$ bundle install
63
74
$ rails webpacker:install # OR (on rails version < 5.0) rake webpacker:install
64
- $ rails webpacker:install:react # OR (on rails version < 5.0) rake webpacker:install:react
65
75
$ rails generate react:install
76
+ $ rails webpacker:install:react # OR (on rails version < 5.0) rake webpacker:install:react
66
77
```
67
78
68
79
This gives you:
@@ -74,7 +85,7 @@ This gives you:
74
85
Link the JavaScript pack in Rails view using ` javascript_pack_tag ` [ helper] ( https://github.com/rails/webpacker#usage ) , for example:
75
86
76
87
```
77
- <!-- application.html.erb -->
88
+ <!-- application.html.erb in Head tag below turbolinks -->
78
89
<%= javascript_pack_tag 'application' %>
79
90
```
80
91
@@ -94,10 +105,15 @@ $ rails g react:component my_subdirectory/HelloWorld greeting:string
94
105
95
106
[ Render it in a Rails view] ( #view-helper ) :
96
107
97
- ``` erb
108
+ ``` erb: paste this in view
98
109
<%= react_component("HelloWorld", { greeting: "Hello" }) %>
99
110
```
100
111
112
+ Lets Start the app:
113
+ ```
114
+ $ rails s
115
+ ```
116
+
101
117
The component name tells ` react-rails ` where to load the component. For example:
102
118
103
119
` react_component ` call | component ` require `
You can’t perform that action at this time.
0 commit comments