You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@
13
13
- Provide [various `react` builds](#reactjs-builds) to your asset bundle
14
14
- Transform [`.jsx` in the asset pipeline](#jsx)
15
15
-[Render components into views and mount them](#rendering--mounting) via view helper & `react_ujs`
16
-
-[Render components server-side](#server-rendering) with `prerender: true`.
16
+
-[Render components server-side](#server-rendering) with `prerender: true`
17
17
-[Generate components](#component-generator) with a Rails generator
18
18
19
19
## Installation
@@ -24,7 +24,7 @@ Add `react-rails` to your gemfile:
24
24
gem 'react-rails', '~> 1.0'
25
25
```
26
26
27
-
Next, run the installation script.
27
+
Next, run the installation script:
28
28
29
29
```bash
30
30
rails g react:install
@@ -93,7 +93,7 @@ Component = React.createClass
93
93
94
94
### Rendering & mounting
95
95
96
-
`react-rails` includes a view helper (`react_component`) and an unobtrusive JavaScript driver (`react_ujs`) which work together to put React components on the page. You should require the UJS driver in your manifest after `react` (and after `turbolinks` if you use [Turbolinks](https://github.com/rails/turbolinks))
96
+
`react-rails` includes a view helper (`react_component`) and an unobtrusive JavaScript driver (`react_ujs`) which work together to put React components on the page. You should require the UJS driver in your manifest after `react` (and after `turbolinks` if you use [Turbolinks](https://github.com/rails/turbolinks)).
97
97
98
98
The __view helper__ puts a `div` on the page with the requested component class & props. For example:
99
99
@@ -107,14 +107,14 @@ On page load, the __`react_ujs` driver__ will scan the page and mount components
107
107
108
108
`react_ujs` uses Turbolinks events if they're available, otherwise, it uses native events. __Turbolinks >= 2.4.0__ is recommended because it exposes better events.
-`component_class_name` is a string which names a globally-accessible component class. It may have dots (eg, `"MyApp.Header.MenuItem"`).
117
-
-`props` is either an object that responds to `#to_json` or an already-stringified JSON object (eg, made with Jbuilder, see note below)
117
+
-`props` is either an object that responds to `#to_json` or an already-stringified JSON object (eg, made with Jbuilder, see note below).
118
118
-`html_options` may include:
119
119
-`tag:` to use an element other than a `div` to embed `data-react-class` and `-props`.
120
120
-`prerender: true` to render the component on the server.
@@ -137,7 +137,7 @@ _(It will be also be mounted by the UJS on page load.)_
137
137
138
138
There are some requirements for this to work:
139
139
140
-
-`react-rails` must load your code. By convention, it uses `components.js`, which was created by the install task. This file must include your components _and_ their dependencies (eg, Underscore.js).
140
+
-`react-rails` must load your code. By convention it uses `components.js`, which was created by the install task. This file must include your components _and_ their dependencies (eg, Underscore.js).
141
141
- Your components must be accessible in the global scope. If you are using `.js.jsx.coffee` files then the wrapper function needs to be taken into account:
142
142
143
143
```coffee
@@ -171,7 +171,7 @@ end
171
171
172
172
### Component generator
173
173
174
-
react-rails ships with a Rails generator to help you get started with a simple component scaffold. You can run it using `rails generate react:component ComponentName`. The generator takes an optional list of arguments for default propTypes, which follow the conventions set in the [Reusable Components](http://facebook.github.io/react/docs/reusable-components.html) section of the React documentation.
174
+
`react-rails` ships with a Rails generator to help you get started with a simple component scaffold. You can run it using `rails generate react:component ComponentName`. The generator takes an optional list of arguments for default propTypes, which follow the conventions set in the [Reusable Components](http://facebook.github.io/react/docs/reusable-components.html) section of the React documentation.
175
175
176
176
For example:
177
177
@@ -218,9 +218,9 @@ The generator can use the following arguments to create basic propTypes:
218
218
219
219
The following additional arguments have special behavior:
220
220
221
-
*`instanceOf` takes an optional class name in the form of {className}
221
+
*`instanceOf` takes an optional class name in the form of {className}.
222
222
*`oneOf` behaves like an enum, and takes an optional list of strings in the form of `'name:oneOf{one,two,three}'`.
223
-
*`oneOfType` takes an optional list of react and custom types in the form of `'model:oneOfType{string,number,OtherType}'`
223
+
*`oneOfType` takes an optional list of react and custom types in the form of `'model:oneOfType{string,number,OtherType}'`.
224
224
225
225
Note that the arguments for `oneOf` and `oneOfType` must be enclosed in single quotes to prevent your terminal from expanding them into an argument list.
0 commit comments