Sha256: 03e7777a8ff759bbc486a3664643cf7b2aaef04614848ab0c8bee1ce892cf497

Contents?: true

Size: 561 Bytes

Versions: 2

Compression:

Stored size: 561 Bytes

Contents

class Route < Preact::Component
  render do
    route_match = @context[:router][:matcher].call(props[:path], @context[:location])
    matches, params = props[:match] || route_match
    return unless 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
Route.context_type = RouterContext

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
isomorfeus-preact-22.9.0.rc6 lib/route.rb
isomorfeus-preact-22.9.0.rc5 lib/route.rb