ruby-hyperloop / hyper-react

The project has moved to Hyperstack!!
https://hyperstack.org/
MIT License
285 stars 14 forks source link

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

Open catmando opened 5 years ago

catmando commented 5 years ago

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.