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
On page load, the __`react_ujs` driver__ will scan the page and mount components using `data-react-class`
136
+
On page load, the __`react_ujs` driver__ will scan the page and mount components using `data-react-class`
137
137
and `data-react-props`.
138
138
139
139
If Turbolinks is present components are mounted on the `page:change` event, and unmounted on `page:before-unload`.
@@ -169,9 +169,9 @@ _(It will be also be mounted by the UJS on page load.)_
169
169
170
170
There are some requirements for this to work:
171
171
172
-
-`react-rails` must load your code. By convention it uses `components.js`, which was created
172
+
-`react-rails` must load your code. By convention it uses `components.js`, which was created
173
173
by the install task. This file must include your components _and_ their dependencies (eg, Underscore.js).
174
-
- Your components must be accessible in the global scope.
174
+
- Your components must be accessible in the global scope.
175
175
If you are using `.js.jsx.coffee` files then the wrapper function needs to be taken into account:
176
176
177
177
```coffee
@@ -180,7 +180,7 @@ If you are using `.js.jsx.coffee` files then the wrapper function needs to be ta
180
180
render:->
181
181
`<ExampleComponent videos={this.props.videos} />`
182
182
```
183
-
- Your code can't reference `document`. Prerender processes don't have access to `document`,
183
+
- Your code can't reference `document`. Prerender processes don't have access to `document`,
184
184
so jQuery and some other libs won't work in this environment :(
185
185
186
186
You can configure your pool of JS virtual machines and specify where it should load code:
@@ -222,10 +222,10 @@ By default, your current layout will be used and the component, rather than a vi
222
222
223
223
### Component generator
224
224
225
-
`react-rails` ships with a Rails generator to help you get started with a simple component scaffold.
226
-
You can run it using `rails generate react:component ComponentName (--es6)`.
227
-
The generator takes an optional list of arguments for default propTypes,
228
-
which follow the conventions set in the [Reusable Components](http://facebook.github.io/react/docs/reusable-components.html)
225
+
`react-rails` ships with a Rails generator to help you get started with a simple component scaffold.
226
+
You can run it using `rails generate react:component ComponentName (--es6)`.
227
+
The generator takes an optional list of arguments for default propTypes,
228
+
which follow the conventions set in the [Reusable Components](http://facebook.github.io/react/docs/reusable-components.html)
229
229
section of the React documentation.
230
230
231
231
For example:
@@ -294,7 +294,7 @@ Note that the arguments for `oneOf` and `oneOfType` must be enclosed in single q
294
294
295
295
### Jbuilder & react-rails
296
296
297
-
If you use Jbuilder to pass a JSON string to `react_component`, make sure your JSON is a stringified hash,
297
+
If you use Jbuilder to pass a JSON string to `react_component`, make sure your JSON is a stringified hash,
298
298
not an array. This is not the Rails default -- you should add the root node yourself. For example:
299
299
300
300
```ruby
@@ -313,7 +313,7 @@ end
313
313
314
314
## CoffeeScript
315
315
316
-
It is possible to use JSX with CoffeeScript. To use CoffeeScript, create files with an extension `.js.jsx.coffee`.
316
+
It is possible to use JSX with CoffeeScript. To use CoffeeScript, create files with an extension `.js.jsx.coffee`.
317
317
We also need to embed JSX code inside backticks so that CoffeeScript ignores the syntax it doesn't understand.
318
318
Here's an example:
319
319
@@ -348,8 +348,8 @@ Any subclass of `ExecJSRenderer` may use those hooks (for example, `SprocketsRen
348
348
`react-rails` uses a "helper implementation" class to generate the output of the `react_component` helper. The helper is initialized once per request and used for each `react_component` call during that request. You can provide a custom helper class to `config.react.view_helper_implementation`. The class must implement:
349
349
350
350
-`#react_component(name, props = {}, options = {}, &block)` to return a string to inject into the Rails view
351
-
-`#setup(rack_env)`, called when the helper is initialized at the start of the request
352
-
-`#teardown(rack_env)`, called at the end of the request
351
+
-`#setup(controller_instance)`, called when the helper is initialized at the start of the request
352
+
-`#teardown(controller_instance)`, called at the end of the request
353
353
354
354
`react-rails` provides one implementation, `React::Rails::ComponentMount`.
0 commit comments