Skip to content

Commit ca8cd8c

Browse files
Update RailsContext type to make rscPayloadGenerationUrl optional
1 parent e5635b9 commit ca8cd8c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/react_on_rails/helper.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def json_safe_and_pretty(hash_or_string)
358358
# second parameter passed to both component and store Render-Functions.
359359
# This method can be called from views and from the controller, as `helpers.rails_context`
360360
#
361-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
361+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
362362
def rails_context(server_side: true)
363363
# ALERT: Keep in sync with node_package/src/types/index.ts for the properties of RailsContext
364364
@rails_context ||= begin
@@ -376,10 +376,12 @@ def rails_context(server_side: true)
376376
rorVersion: ReactOnRails::VERSION,
377377
# TODO: v13 just use the version if existing
378378
rorPro: ReactOnRails::Utils.react_on_rails_pro?,
379-
rscPayloadGenerationUrl: rsc_url
380379
}
380+
381381
if ReactOnRails::Utils.react_on_rails_pro?
382382
result[:rorProVersion] = ReactOnRails::Utils.react_on_rails_pro_version
383+
384+
result[:rscPayloadGenerationUrl] = rsc_url if ReactOnRailsPro.configuration.enable_rsc_support
383385
end
384386

385387
if defined?(request) && request.present?
@@ -437,7 +439,7 @@ def load_pack_for_generated_component(react_component_name, render_options)
437439
append_stylesheet_pack_tag("generated/#{react_component_name}")
438440
end
439441

440-
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
442+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
441443

442444
private
443445

node_package/src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type RailsContext = {
3434
pathname: string;
3535
search: string | null;
3636
httpAcceptLanguage: string;
37-
rscPayloadGenerationUrl: string;
37+
rscPayloadGenerationUrl?: string;
3838
} & (
3939
| {
4040
serverSide: false;

0 commit comments

Comments
 (0)