Skip to content

Commit 043fc25

Browse files
Add RSC support configuration check and clean up comments
- Add configuration check to raise an error if RSC support is not enabled - Remove TODO comment for uploading RSC assets - Clean up comments in application layout view - Remove unnecessary instance variable reset in test helper
1 parent bd0e78f commit 043fc25

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

lib/react_on_rails_pro/request.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ def render_code(path, js_code, send_bundle)
2020

2121
def render_code_as_stream(path, js_code, is_rsc_payload:)
2222
Rails.logger.info { "[ReactOnRailsPro] Perform rendering request as a stream #{path}" }
23+
if is_rsc_payload && !ReactOnRailsPro.configuration.enable_rsc_support
24+
raise ReactOnRailsPro::Error,
25+
"RSC support is not enabled. Please set enable_rsc_support to true in your " \
26+
"config/initializers/react_on_rails_pro.rb file before " \
27+
"rendering any RSC payload."
28+
end
29+
2330
ReactOnRailsPro::StreamRequest.create do |send_bundle|
2431
form = form_with_code(js_code, send_bundle, is_rsc_payload: is_rsc_payload)
2532
perform_request(path, form: form, stream: true)
2633
end
2734
end
2835

29-
# TODO: add support for uploading rsc assets
3036
def upload_assets
3137
Rails.logger.info { "[ReactOnRailsPro] Uploading assets" }
3238
perform_request("/upload-assets", form: form_with_assets_and_bundle)

spec/dummy/app/views/layouts/application.html.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
media: 'all',
2323
'data-turbolinks-track': true) %>
2424

25-
<!-- NOTE: Must use defer and not async to keep async scripts loading in correct order -->
26-
<!-- TODO: Investigate and resolve potential issues with async loading when components are split into multiple chunks -->
25+
<%# Used for testing purposes to simulate hydration failure %>
2726
<% unless params[:skip_js_packs] == 'true' %>
28-
<%# Used for testing purposes to simulate hydration failure %>
2927
<%= javascript_pack_tag('client-bundle', 'data-turbolinks-track': true, defer: false) %>
3028
<% end %>
3129
<%= csrf_meta_tags %>

spec/dummy/spec/helpers/react_on_rails_pro_helper_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ def response; end
225225
def mock_request_and_response(mock_chunks = chunks)
226226
# Reset connection instance variables to ensure clean state for tests
227227
ReactOnRailsPro::Request.instance_variable_set(:@connection, nil)
228-
ReactOnRailsPro::Request.instance_variable_set(:@rsc_connection, nil)
229228
original_httpx_plugin = HTTPX.method(:plugin)
230229
allow(HTTPX).to receive(:plugin) do |*args|
231230
original_httpx_plugin.call(:mock_stream).plugin(*args)

spec/dummy/yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5567,7 +5567,7 @@ raw-body@2.5.2:
55675567
iconv-lite "0.4.24"
55685568
unpipe "1.0.0"
55695569

5570-
react-dom@^19.0.0:
5570+
react-dom@19.0.0:
55715571
version "19.0.0"
55725572
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-19.0.0.tgz#43446f1f01c65a4cd7f7588083e686a6726cfb57"
55735573
integrity sha512-4GV5sHFG0e/0AD4X+ySy6UJd3jVl1iNsNHdpad0qhABJ11twS3TTBnseqsKurKcsNqCEFeGL3uLpVChpIO3QfQ==
@@ -5661,7 +5661,7 @@ react-side-effect@^2.1.0:
56615661
resolved "https://registry.yarnpkg.com/react-side-effect/-/react-side-effect-2.1.2.tgz#dc6345b9e8f9906dc2eeb68700b615e0b4fe752a"
56625662
integrity sha512-PVjOcvVOyIILrYoyGEpDN3vmYNLdy1CajSFNt4TDsVQC5KpTijDvWVoR+/7Rz2xT978D8/ZtFceXxzsPwZEDvw==
56635663

5664-
react@^19.0.0:
5664+
react@19.0.0:
56655665
version "19.0.0"
56665666
resolved "https://registry.yarnpkg.com/react/-/react-19.0.0.tgz#6e1969251b9f108870aa4bff37a0ce9ddfaaabdd"
56675667
integrity sha512-V8AVnmPIICiWpGfm6GLzCR/W5FXLchHop40W4nXBmdlEceh16rCN8O8LNWm5bh5XUX91fh7KpA+W0TgMKmgTpQ==

0 commit comments

Comments
 (0)