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

lap28 hyper-router history regression #17

@catmando

Description

@catmando

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions