Skip to content

Commit 919f3e9

Browse files
committed
Update Turbolinks doc and release notes
1 parent ae71103 commit 919f3e9

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

docs/rails/turbolinks.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Async script loading can be done like this:
8484
<%= javascript_include_tag 'application', async: Rails.env.production? %>
8585
```
8686

87-
If you use `document.addEventListener("turbolinks:load", function() {...});` somewhere in your code, you will notice that Turbolinks 5 does not fire `turbolinks:load` on initial page load. A quick workaround is to use `defer` instead of `async`:
87+
If you use `document.addEventListener("turbolinks:load", function() {...});` somewhere in your code, you will notice that Turbolinks 5 does not fire `turbolinks:load` on initial page load. A quick workaround for React on Rails <15 is to use `defer` instead of `async`:
8888

8989
```erb
9090
<%= javascript_include_tag 'application', defer: Rails.env.production? %>
@@ -100,6 +100,8 @@ document.addEventListener('turbolinks:load', function () {
100100
});
101101
```
102102

103+
React on Rails 15 fixes both issues, so if you still have the listener it can be removed (and should be as `reactOnRailsPageLoaded()` is now async).
104+
103105
## Troubleshooting
104106

105107
To turn on tracing of Turbolinks events, put this in your registration file, where you register your components.

docs/release-notes/15.0.0.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,25 @@ Major improvements to component and store hydration:
3030
- The previous need for deferring scripts to prevent race conditions has been eliminated due to improved hydration handling. Making scripts not defer is critical to execute the hydration scripts early before the page is fully loaded.
3131
- The `force_load` configuration makes `react-on-rails` hydrate components immediately as soon as their server-rendered HTML reaches the client, without waiting for the full page load.
3232
- If you want to keep the previous behavior, you can set `defer_generated_component_packs: true` or `force_load: false` in your `config/initializers/react_on_rails.rb` file.
33-
- To do that for only some components, you can call `force_load: false` in the `react_component` helper or `force_load` configuration.
34-
- Redux store now supports `force_load` option, and uses `config.force_load` value as the default value. Which means that the Redux store will hydrate immediately as soon as its server-side data reaches the client. You can override this behavior for individual Redux stores by calling the `redux_store` helper with `force_load: false`.
33+
- You can also keep it for individual components by passing `force_load: false` to `react_component` or `stream_react_component`.
34+
- Redux store now supports `force_load` option, and uses `config.force_load` value as the default value. Which means that the Redux store will hydrate immediately as soon as its server-side data reaches the client.
35+
- You can override this behavior for individual Redux stores by calling the `redux_store` helper with `force_load: false`, same as `react_component`.
3536

3637
- `ReactOnRails.reactOnRailsPageLoaded()` is now an async function:
3738

38-
- If you are manually calling this function to ensure components are hydrated (e.g. with async script loading), you must now await the promise it returns:
39+
- If you manually call this function to ensure components are hydrated (e.g., with async script loading), you must now await the promise it returns:
3940

40-
```js
41-
// Before
42-
ReactOnRails.reactOnRailsPageLoaded();
43-
// Code expecting all components to be hydrated
41+
```js
42+
// Before
43+
ReactOnRails.reactOnRailsPageLoaded();
44+
// Code expecting all components to be hydrated
4445

45-
// After
46-
await ReactOnRails.reactOnRailsPageLoaded();
47-
// Code expecting all components to be hydrated
48-
```
46+
// After
47+
await ReactOnRails.reactOnRailsPageLoaded();
48+
// Code expecting all components to be hydrated
49+
```
50+
51+
- If you call it in a `turbolinks:load` listener to work around the issue documented in [Turbolinks](../rails/turbolinks.md#async-script-loading), the listener can be safely removed.
4952

5053
## Store Dependencies for Components
5154

0 commit comments

Comments
 (0)