Hacker News new | comments | show | ask | jobs | submit login
React.native isn't (metaobject.com)
8 points by mpweiher 899 days ago | hide | past | web | 5 comments | favorite



I would like to hear more discussion on this subject, since there seems to be a confusion in the community regarding MVC (myself included.) see also author's previous article http://blog.metaobject.com/2015/04/model-widget-controller-m...

I'm a React developer, have little experience with native development myself. With that in mind, here is a small implementation of how I would envision how developing a native app with React's always rendering in mind: https://github.com/ustun/mvc-vs-react/blob/master/singleview...

Notice every UI action results in a call to a model method, immediately follows by render. The whole model-view syncronization is centralized in a render method, so it is not allowed to modify view manually in UIAction methods, you just set model methods and then render.

What React does is to make this seamless, that is you call setState which in turn triggers render automatically. This way, the data flows from your model to your view.

Of course this doesn't take into account how this flow goes when child views are involved, normally you would want to call render in each childview as well, and that's where virtual DOM comes into play with React.


You should read this article form Martin Fowler: http://martinfowler.com/eaaDev/uiArchs.html

It has an excellent analysis about GUI architectures. This problem is not new and as such, there are already proposals to solve it. Every proposal has his pros and cons. It is a shame that we prefer to immediately "invent" our solutions instead of first looking to the past and check how it has been solved. A lot of people has told me that is not important to know the how and why things work in order to be a good developer, but this is exactly what happen when you have a lot of developers that don't understand the fundamentals


> It is a shame that we prefer to immediately "invent" our solutions

Exactly, that is one of the reasons why I started to work on this: http://mvc.givan.se/


Very nice, I think you should include some Sequence Diagrams to explain the differences between them :-)


Thanks for the pointer!




Applications are open for YC Winter 2018

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: