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: CHANGELOG.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,13 @@ If you think ShakaCode can help your project, [click here](https://meetings.hubs
15
15
Please follow the recommendations outlined at [keepachangelog.com](http://keepachangelog.com/). Please use the existing headings and styling as a guide, and add a link for the version diff at the bottom of the file. Also, please update the `Unreleased` link to compare to the latest release version.
16
16
17
17
## Versions
18
+
### [Unreleased]
19
+
#### Added
20
+
- Configuration option `generated_component_packs_loading_strategy` to control how generated component packs are loaded. It supports `sync`, `async`, and `defer` strategies. [PR 1707](https://github.com/shakacode/react_on_rails/pull/1707) by [judahmeek](https://github.com/judahmeek).
21
+
22
+
### Removed (Breaking Changes)
23
+
- Removed `defer_generated_component_packs` configuration option. You can use `generated_component_packs_loading_strategy` instead. [PR 1707](https://github.com/shakacode/react_on_rails/pull/1707) by [judahmeek](https://github.com/judahmeek).
Copy file name to clipboardExpand all lines: docs/release-notes/15.0.0.md
+22-6Lines changed: 22 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,13 +17,24 @@ Major improvements to component and store hydration:
17
17
- Can use `async` scripts in the page with no fear of race condition
18
18
- No need to use `defer` anymore
19
19
20
+
### Enhanced Script Loading Strategies
21
+
- New configuration option `generated_component_packs_loading_strategy` replaces `defer_generated_component_packs`
22
+
- Supports three loading strategies:
23
+
-`:async` - Loads scripts asynchronously (default for Shakapacker ≥ 8.2.0)
24
+
-`:defer` - Defers script execution until after page load (Doesn't work good with Streamed HTML as it will wait for the full page load before hydrating the components)
25
+
-`:sync` - Loads scripts synchronously (default for Shakapacker < 8.2.0) (Better to upgrade to Shakapacker 8.2.0 and use `:async` strategy)
26
+
- Improves page performance by optimizing how component packs are loaded
27
+
20
28
## Breaking Changes
21
29
22
30
### Component Hydration Changes
23
-
- The `defer_generated_component_packs` and `force_load` configurations now default to `false` and `true` respectively. This means components will hydrate early without waiting for the full page load. This improves performance by eliminating unnecessary delays in hydration.
31
+
- The `defer_generated_component_packs` configuration has been removed. Use `generated_component_packs_loading_strategy` instead.
32
+
- The `generated_component_packs_loading_strategy` defaults to `:async` for Shakapacker ≥ 8.2.0 and `:sync` for Shakapacker < 8.2.0.
33
+
- The `force_load` configuration now defaults to `true`.
34
+
- The new default values of `generated_component_packs_loading_strategy: :async` and `force_load: true` work together to optimize component hydration. Components now hydrate as soon as their code and server-rendered HTML are available, without waiting for the full page to load. This parallel processing significantly improves time-to-interactive by eliminating the traditional waterfall of waiting for page load before beginning hydration (It's critical for streamed HTML).
24
35
- 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.
25
36
- The `force_load` configuration make `react-on-rails` hydrate components immediately as soon as their server-rendered HTML reaches the client, without waiting for the full page load.
26
-
- 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.
37
+
- If you want to keep the previous behavior, you can set `generated_component_packs_loading_strategy: :defer` or `force_load: false` in your `config/initializers/react_on_rails.rb` file.
27
38
- If we want to keep the original behavior of `force_load` for only one or more components, you can set `force_load: false` in the `react_component` helper or `force_load` configuration.
28
39
- Redux store support `force_load` option now and it 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 setting `force_load: false` in the `redux_store` helper.
29
40
@@ -39,6 +50,11 @@ Major improvements to component and store hydration:
39
50
// Code expecting all components to be hydrated
40
51
```
41
52
53
+
### Script Loading Strategy Migration
54
+
- If you were previously using `defer_generated_component_packs: true`, use `generated_component_packs_loading_strategy: :defer` instead
55
+
- If you were previously using `defer_generated_component_packs: false`, use `generated_component_packs_loading_strategy: :sync` instead
56
+
- For optimal performance with Shakapacker ≥ 8.2.0, consider using `generated_component_packs_loading_strategy: :async`
57
+
42
58
## Store Dependencies for Components
43
59
44
60
When using Redux stores with multiple components, you need to explicitly declare store dependencies to optimize hydration. Here's how:
@@ -65,12 +81,12 @@ Explicitly declare store dependencies for each component:
0 commit comments