@@ -54,12 +54,11 @@ module Helper
5454 # random_dom_id can be set to override the default from the config/initializers. That's only
5555 # used if you have multiple instance of the same component on the Rails view.
5656 def react_component ( component_name , options = { } )
57- badge = pro_warning_badge_if_needed ( render_options . force_load )
58- render_options . set_option ( :force_load , false ) unless support_pro_features?
5957 internal_result = internal_react_component ( component_name , options )
6058 server_rendered_html = internal_result [ :result ] [ "html" ]
6159 console_script = internal_result [ :result ] [ "consoleReplayScript" ]
6260 render_options = internal_result [ :render_options ]
61+ badge = pro_warning_badge_if_needed ( internal_result [ :force_load_requested ] )
6362
6463 case server_rendered_html
6564 when String
@@ -211,13 +210,12 @@ def rsc_payload_react_component(component_name, options = {})
211210 #
212211 def react_component_hash ( component_name , options = { } )
213212 options [ :prerender ] = true
214- badge = pro_warning_badge_if_needed ( render_options . force_load )
215- render_options . set_option ( :force_load , false ) unless support_pro_features?
216213
217214 internal_result = internal_react_component ( component_name , options )
218215 server_rendered_html = internal_result [ :result ] [ "html" ]
219216 console_script = internal_result [ :result ] [ "consoleReplayScript" ]
220217 render_options = internal_result [ :render_options ]
218+ badge = pro_warning_badge_if_needed ( internal_result [ :force_load_requested ] )
221219
222220 if server_rendered_html . is_a? ( String ) && internal_result [ :result ] [ "hasErrors" ]
223221 server_rendered_html = { COMPONENT_HTML_KEY => internal_result [ :result ] [ "html" ] }
@@ -674,6 +672,9 @@ def internal_react_component(react_component_name, options = {})
674672 # server has already rendered the HTML.
675673
676674 render_options = create_render_options ( react_component_name , options )
675+ # Capture the originally requested value so we can show a badge while still disabling the feature.
676+ force_load_requested = render_options . force_load
677+ render_options . set_option ( :force_load , false ) unless support_pro_features?
677678
678679 # Setup the page_loaded_js, which is the same regardless of prerendering or not!
679680 # The reason is that React is smart about not doing extra work if the server rendering did its job.
@@ -703,7 +704,8 @@ def internal_react_component(react_component_name, options = {})
703704 {
704705 render_options : render_options ,
705706 tag : component_specification_tag ,
706- result : result
707+ result : result ,
708+ force_load_requested : force_load_requested
707709 }
708710 end
709711
0 commit comments