Skip to content
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.

lap28 hyper-router history regression #17

Open
catmando opened this issue May 7, 2018 · 1 comment
Open

lap28 hyper-router history regression #17

catmando opened this issue May 7, 2018 · 1 comment

Comments

@catmando
Copy link
Contributor

catmando commented May 7, 2018

the fix for issue #15 was put into Hyper::Router::Mixin rather than Hyper::Router::Base. This means that every component creating a HyperRouter component (like using NavLink etc) was also adding a before_mount callback. But more critically the fix was using before_mount instead of after_mount so it was being invoked during prerrendering.

The actual code should look like this:

module Hyperloop
  class Router
    module Base
      ...
        base.class_eval do
          after_mount do # thas was in Hyperloop::Router::Mixin BEFORE_MOUNT
            @_react_router_unlisten = history.listen do |location, _action|
              React::State.set_state(HyperRouter, :location, location)
            end
          end

          before_unmount do
            @_react_router_unlisten.call if @_react_router_unlisten
          end
        end
      end
    end
  end
end
catmando added a commit that referenced this issue May 7, 2018
@sfcgeorge
Copy link

Looks like this issue can be closed, wasn't auto-closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants