Sha256: e03a21faa5e6a680d6f4a5ef3f18c07f0ec905de7dd1c886ec532ad9e170e57e

Contents?: true

Size: 590 Bytes

Versions: 20

Compression:

Stored size: 590 Bytes

Contents

class Route < Preact::Component

  self.context_type = RouterContext

  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)
        RPE(Preact.create_element(component, component_props.merge!({ params: params })))
      else
        RPE(props[:children])
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
isomorfeus-preact-23.9.0.rc12 lib/route.rb
isomorfeus-preact-23.9.0.rc11 lib/route.rb
isomorfeus-preact-23.9.0.rc10 lib/route.rb
isomorfeus-preact-23.9.0.rc9 lib/route.rb
isomorfeus-preact-23.9.0.rc8 lib/route.rb
isomorfeus-preact-23.9.0.rc7 lib/route.rb
isomorfeus-preact-23.9.0.rc6 lib/route.rb
isomorfeus-preact-23.9.0.rc5 lib/route.rb
isomorfeus-preact-23.9.0.rc4 lib/route.rb
isomorfeus-preact-23.9.0.rc3 lib/route.rb
isomorfeus-preact-23.9.0.rc2 lib/route.rb
isomorfeus-preact-23.9.0.rc1 lib/route.rb
isomorfeus-preact-23.8.0.rc3 lib/route.rb
isomorfeus-preact-23.8.0.rc2 lib/route.rb
isomorfeus-preact-23.8.0.rc1 lib/route.rb
isomorfeus-preact-23.7.0.rc5 lib/route.rb
isomorfeus-preact-23.7.0.rc4 lib/route.rb
isomorfeus-preact-23.7.0.rc3 lib/route.rb
isomorfeus-preact-23.7.0.rc2 lib/route.rb
isomorfeus-preact-23.7.0.rc1 lib/route.rb