Class: Proscenium::ViewComponent::ReactComponent

Inherits:
Proscenium::ViewComponent show all
Includes:
ReactComponentable
Defined in:
lib/proscenium/view_component/react_component.rb

Overview

Renders a <div> for use with React components, with data attributes specifying the component path and props.

If a content block is given, that content will be rendered inside the component, allowing for a “loading” UI. If no block is given, then a “loading…” text will be rendered. It is intended that the component is mounted to this div, and the loading UI will then be replaced with the component’s rendered output.

Instance Method Summary collapse

Methods included from ReactComponentable

#initialize, #props, #virtual_path

Methods inherited from Proscenium::ViewComponent

inherited, sideload_assets

Methods included from CssModules

included

Methods included from CssModule

#class_names, #css_module

Methods included from SourcePath

included

Instance Method Details

#callObject



16
17
18
19
20
# File 'lib/proscenium/view_component/react_component.rb', line 16

def call
  tag.send root_tag, data: data_attributes do
    tag.div content || 'loading...'
  end
end