These are chat archives for opal/opal

25th
Nov 2016
Forrest Chang
@fkchang
Nov 25 2016 20:25

@elia trying opal master with hyper-react, get an unexpected error w/code that ran fine on 0.10.3 undefined method `_name' for #<Class:React> This apparently gets called on the define_method _name line while loading require 'rails-helpers/top_level_rails_component' which is getting called when requiring hyper-react

      class << self
        def included(component)
          _name, parent = find_name_and_parent(component)
          class << parent
            define_method _name do |*params, &children|
              React::RenderingContext.render(component, *params, &children)
            end

Looks like _name gets defined just 2 lines earlier

Elia Schito
@elia
Nov 25 2016 20:35

@fkchang Can you publish an example app I can look into? Or alternatively instructions I can reproduce.

Looks like a scoping issue

Elia Schito
@elia
Nov 25 2016 22:15
@fkchang runnning this on MRI gives the same error:
module M
  class << self
    def included(component)
      _name, parent = 'foo', 'bar'
      class << parent
        define_method _name do |*params, &children|
          p params
        end  
      end
    end
  end
end

class C
  include M
end
so I think it's hyper-react that needs to be fixed, maybe you could just do parent.define_singleton_method _name do |*params, &children| … end
Forrest Chang
@fkchang
Nov 25 2016 23:46
Curious, worked under 0.10.3
@barriehadfield @catmando surprised it worked before