Module: ReactOnRails::ReactComponent

Defined in:
lib/react_on_rails/react_component/render_options.rb

Defined Under Namespace

Classes: RenderOptions

Constant Summary collapse

HYDRATE_ON_MODES =
%i[immediate visible idle].freeze

Class Method Summary collapse

Class Method Details

.normalize_hydrate_on(value) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/react_on_rails/react_component/render_options.rb', line 9

def self.normalize_hydrate_on(value)
  normalized_value = value.is_a?(String) ? value.to_sym : value
  unless HYDRATE_ON_MODES.include?(normalized_value)
    raise ArgumentError,
          "Invalid hydrate_on option: #{value.inspect}. " \
          "Supported OSS modes are :immediate, :visible, and :idle."
  end

  return normalized_value if normalized_value == :immediate || !ReactOnRails::Utils.react_on_rails_pro?

  raise ArgumentError,
        "hydrate_on: #{value.inspect} is only supported by the open-source React on Rails client renderer. " \
        "React on Rails Pro does not support hydrate_on scheduling yet; use :immediate."
end