Sha256: d5828e8ae72e6d07cb2a805285b641f1f5b5763c48c048ab13045f5c3364399f
Contents?: true
Size: 1.07 KB
Versions: 12
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Proscenium # Renders a <div> for use with React components, with data attributes specifying the component # path and props. # # If a block is given, it will be yielded within the div, allowing for a custom "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. # # You can pass props to the component in the `:props` keyword argument. class Phlex::ReactComponent < Phlex self.abstract_class = true include ReactComponentable # Override this to provide your own loading UI. # # @example # def view_template(**attributes, &block) # super do # 'Look at me! I am loading now...' # end # end # # @yield the given block to a `div` within the top level component div. def view_template(**attributes, &block) send root_tag, **{ data: data_attributes }.deep_merge(attributes), &block end end end
Version data entries
12 entries across 12 versions & 1 rubygems