2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-05-06 18:07:29 +02:00
|
|
|
class ReactComponent < ApplicationComponent
|
|
|
|
erb_template <<-ERB
|
|
|
|
<% if content? %>
|
|
|
|
<react-component name=<%= @name %> props="<%= @props.to_json %>"><%= content %></react-component>
|
|
|
|
<% else %>
|
|
|
|
<react-component name=<%= @name %> props="<%= @props.to_json %>"></react-component>
|
|
|
|
<% end %>
|
|
|
|
ERB
|
|
|
|
|
|
|
|
def initialize(name, **props)
|
|
|
|
@name = name
|
|
|
|
@props = props
|
|
|
|
end
|
|
|
|
end
|