Skip to content

Commit 1d18a8e

Browse files
committed
update docs for global fallback
1 parent cd513c8 commit 1d18a8e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ $ rails g react:install
3434

3535
## Use with Webpacker
3636

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`:
3840

3941
```
4042
$ rails webpacker:install
@@ -65,6 +67,8 @@ The component name tells `react-rails` where to load the component. For example:
6567

6668
This way, you can access top-level, default, or named exports.
6769

70+
If `require` fails, `react-rails` falls back to the global namespace approach described in [Use with Asset Pipeline](#use-with-asset-pipeline).
71+
6872
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`:
6973

7074
```js
@@ -74,8 +78,6 @@ var ReactRailsUJS = require("react_ujs")
7478
ReactRailsUJS.useContext(myCustomContext)
7579
```
7680

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-
7981
## Use with Asset Pipeline
8082

8183
`react-rails` provides React.js & a UJS driver to the Rails asset pipeline. Get started by installing:

0 commit comments

Comments
 (0)