hyper-react
hyper-react copied to clipboard
to_n on Hyperloop::Components should convert back to the js component
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)
done in lap10, needs to be tested
@janbiedermann Did you just implement the patch as shown above or something fancier?
just as above