hyper-react icon indicating copy to clipboard operation
hyper-react copied to clipboard

to_n on Hyperloop::Components should convert back to the js component

Open catmando opened this issue 8 years ago • 3 comments

Some react libs allow a component class to be passed as a "control". There is no easy to convert a Hyperloop::Component to the underlying JS component. It can be done by doing this:

React::API.class_eval('@@component_classes')[MyComponentClass]

so you could implement to_n like this:

class Hyperloop::Component
  def self.to_n 
    React::API.class_eval('@@component_classes')[self]
  end
end

What should really happen is each Hyperloop::Component should save a link to the native class internally, perhaps get rid of React::API's @@component_classes hash, which is left over from the original reactrb implementation

Also we have to do some checks for builtin in tags like DIV, DIV.to_n should probably return 'DIV' (I think)

catmando avatar Sep 09 '17 01:09 catmando

done in lap10, needs to be tested

janbiedermann avatar Dec 11 '17 11:12 janbiedermann

@janbiedermann Did you just implement the patch as shown above or something fancier?

catmando avatar Dec 11 '17 17:12 catmando

just as above

janbiedermann avatar Dec 11 '17 20:12 janbiedermann