Sha256: 537f0710862bbe69e028d80569c63c1a0a9417459a2dbef8fd20ae8aa5223697

Contents?: true

Size: 575 Bytes

Versions: 3

Compression:

Stored size: 575 Bytes

Contents

class Route < Preact::Component
  render do
    route_match = @context[:router][:matcher].call(props[:path], @context[:location])
    matches, params = props[:match] || route_match
    if matches
      component = props[:component]
      component_props = props[:component_props] || {}
      if component
        component = component.constantize if component.is_a?(String)
        Preact.create_element(component, component_props.merge!({ params: params }))
      else
        props[:children]
      end
    end
  end
end
Route.context_type = RouterContext

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
isomorfeus-preact-22.9.0.rc9 lib/route.rb
isomorfeus-preact-22.9.0.rc8 lib/route.rb
isomorfeus-preact-22.9.0.rc7 lib/route.rb