Matt Saginario
Matt Saginario

Reputation: 63

Uncaught error: RuntimeError: Edit does not appear to be a react component

I'm getting the "Uncaught error: RuntimeError: Edit does not appear to be a react component." message, despite having edit defined within the same module:

module Components
  module Admin
    module Discounts
      class Layout < Hyperloop::Router::Component
        render(DIV) do
          Switch do
            Route("#{match.url}/index") do
              Redirect(pathname: match.url, search: location.search)
            end

            Route(match.url, exact: true) do |m, l, h|
              Index(match: m, location: l, history: h)
            end

            Route("#{match.url}/:discount_id/edit") do |m, l, h|
              Edit(match: m, location: l, history: h)
            end

            Route("#{match.url}/new") do |m, l, h|
              New(match: m, location: l, history: h)
            end
          end
        end
      end
    end
  end
end
module Components
  module Admin
    module Discounts
      class Edit < Hyperloop::Router::Component
...

However, I have another file models/edit.rb that seems to be used instead

module Edit
  def backup(attr_whitelist, assoc_whitelist)
    @saved_attributes = attributes_as_json(attr_whitelist, assoc_whitelist)
  end

Any thoughts on why this is happening/how to point to the class Edit instead?

Upvotes: 1

Views: 50

Answers (1)

Mitch VanDuyn
Mitch VanDuyn

Reputation: 2878

Looks like you found a bug!

https://github.com/hyperstack-org/hyperstack/issues/181

It's obscure but if the component class is nested and another module or class is defined at the outer scope, the component lookup fails!

Meanwhile you can

  • pick up the fix on the edge branch
  • patch it as shown on the issue or
  • add the parent module name (i.e. Discount::Edit) the component name when mounting

Upvotes: 1

Related Questions