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
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,9 @@ $ rails g react:install
34
34
35
35
## Use with Webpacker
36
36
37
-
[webpacker](https://github.com/rails/webpacker) integrates modern JS tooling with Rails. Get started by adding `webpacker` to your gemfile and installing `webpacker` and `react-rails`:
37
+
[webpacker](https://github.com/rails/webpacker) integrates modern JS tooling with Rails. `ReactRailsUJS` allows you to gradually migrate to webpacker.
38
+
39
+
Get started by adding `webpacker` to your gemfile and installing `webpacker` and `react-rails`:
38
40
39
41
```
40
42
$ rails webpacker:install
@@ -65,6 +67,8 @@ The component name tells `react-rails` where to load the component. For example:
65
67
66
68
This way, you can access top-level, default, or named exports.
67
69
70
+
If `require` fails, `react-rails` falls back to the global namespace approach described in [Use with Asset Pipeline](#use-with-asset-pipeline).
71
+
68
72
The `require.context` inserted into `packs/application.js` is used to load components. If you want to load components from a different directory, override it by calling `ReactRailsUJS.useContext`:
69
73
70
74
```js
@@ -74,8 +78,6 @@ var ReactRailsUJS = require("react_ujs")
74
78
ReactRailsUJS.useContext(myCustomContext)
75
79
```
76
80
77
-
Alternatively, you can bypass `ReactRailsUJS.useContext` altogether and use the global namespace approach described in [Use with Asset Pipeline](#use-with-asset-pipeline)
78
-
79
81
## Use with Asset Pipeline
80
82
81
83
`react-rails` provides React.js & a UJS driver to the Rails asset pipeline. Get started by installing:
0 commit comments