ruby-hyperloop/hyper-react

clean up how ruby component classes are translated to react component classes

catmando opened this issue · 0 comments

Currently, the first time a ruby component class is passed to createElement, a wrapper react.js component class is created (see react/api.rb)

The lifecycle methods in the wrapper class then call back into the ruby class.

This is not only inefficient but in the case of componentDidCatch it doesn't work, since this means every component class is defined with a componentDidCatch method, where as react assumes only components that will handle an error boundry will have a componentDidCatch method.

So what should happen is that as soon as a the hyperloop component mixin is included in a class, this immediately creates a new react prototype class. Then as each life cycle method is called for the first time, the appropriate hook is added to the prototype class.