lib/hyperstack/internal/router/helpers.rb in hyper-router-1.0.alpha1.2 vs lib/hyperstack/internal/router/helpers.rb in hyper-router-1.0.alpha1.3
- old
+ new
@@ -23,10 +23,13 @@
React::Router::DOM::NavLink(opts, &children)
end
def Redirect(to, opts = {})
opts[:to] = to.to_n
+ status = opts.delete(:status)
+ status ||= 302
+ `#{IsomorphicMethods.ctx}.status = #{status}`
React::Router::Redirect(opts)
end
def format_params(e)
{
@@ -35,10 +38,12 @@
history: Hyperstack::Router::History.new(`#{e}.history`)
}
end
def Route(to, opts = {}, &block)
+ Hyperstack::Internal::State::Mapper.observed! Hyperstack::Router::Location
+
opts[:path] = to.to_n
if opts[:mounts]
component = opts.delete(:mounts)
@@ -51,10 +56,10 @@
if block
opts[:render] = lambda do |e|
route_params = format_params(e)
- yield(route_params.values).to_n
+ yield(*route_params.values).to_n
end
end
React::Router::Route(opts)
end