module ReactOnRails::Helper

def internal_react_component(react_component_name, options = {})

def internal_react_component(react_component_name, options = {})
  # Create the JavaScript and HTML to allow either client or server rendering of the
  # react_component.
  #
  # Create the JavaScript setup of the global to initialize the client rendering
  # (re-hydrate the data). This enables react rendered on the client to see that the
  # server has already rendered the HTML.
  render_options = create_render_options(react_component_name, options)
  # Setup the page_loaded_js, which is the same regardless of prerendering or not!
  # The reason is that React is smart about not doing extra work if the server rendering did its job.
  component_specification_tag = generate_component_script(render_options)
  load_pack_for_generated_component(react_component_name, render_options)
  # Create the HTML rendering part
  result = server_rendered_react_component(render_options)
  {
    render_options: render_options,
    tag: component_specification_tag,
    result: result
  }
end