Hacker News new | past | comments | ask | show | jobs | submit login

I'm a bit scared of what will replace mixins.

I've worked with C++ code bases where inheritance went crazy, and also with C++ code bases where composition via components was well supported and somewhat enforced. I'd love to see ES building in some kind of default support for composition with components if mixins are out.

See also how Unity3D does it: http://docs.unity3d.com/Manual/UsingComponents.html

I'm very happy to see JavaScript advancing, but I really hope we don't end up falling into the same holes other OOP languages fell into and then had to slowly educate and build themselves back out of again over the years. Frontend seems to be very good at rediscovering the old-new.




Yeah it sounds like React's Components could be similar to Unity3D's GameObjects and the replacement for mixins could be similar to Unity3D's Components.

E.g. implementation: SubComponent (or something named better), a component can add the subcomponents to itself on initialization, and the lifecycle events can be similar to the Unity3D's SendMessage, i.e. similar to mixins. I think it would work quite well!

You would need to get the child subcomponent specifically e.g. get the timer subcomponent to create a timer, but as a bonus the subcomponent would not edit the instance of the component, feels cleaner TBH. Also two subcomponents can have the same this.field or this.property, or this.func without worrying about whether it belongs to the Component, another mixin, or something else :D


There's a mixin proposal in the react-future repo:

https://github.com/reactjs/react-future/blob/master/01%20-%2...


love that you mention how Unity handles components. Since I started using React I've been dreaming of an editor that acts like Unity WRT components, and the properties you edit are inferred from `getDefaultProps` and `getDefaultProps`.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: