Live data from Hacker News

Use ReactJS to Build Native Apps

twitter.com

151–160 of 175 posts

Re: Use ReactJS to Build Native Apps

#151

Hi, I'm Jordan from the React team. I'm happy to answer any questions about React Native, but @vjeux will be giving a more thorough talk tomorrow that you won't want to miss (if you're at ReactJSConf), so I might wait for him to answer some of them. This is not the DOM. This is not a web view. If you know ReactJS, you can build native apps with React Native.

Apologies - In at the deep end with a very specific (hardcore?) question.

In Titanium it is difficult, if not impossible without resorting to a Native plug-in (which kinda defeats the object of using it IMHO as this is not 'Learn once, use anywhere'), to re-create an interface similar to the Facebook app. i.e. the vertical scrolling timeline with embedded horizontal scrolling images in each post. (on Android it really does suck) due to issue with memory, threading etc.

So I guess my question is, is it something to that React Native could cope with, or would it potentially suffer from the same memory, threading issues?

And my guess is that at some point it has to surface, so a good architectural comparison would be fab.

Perhaps the Hyperloop/React Native race is on :-)

Re: Use ReactJS to Build Native Apps

#152

Hi, I'm Jordan from the React team. I'm happy to answer any questions about React Native, but @vjeux will be giving a more thorough talk tomorrow that you won't want to miss (if you're at ReactJSConf), so I might wait for him to answer some of them. This is not the DOM. This is not a web view. If you know ReactJS, you can build native apps with React Native.

I also covered some of the performance related questions in another HN thread here ("zero DOM not virtual DOM"): https://news.ycombinator.com/item?id=8964935

I'll try to address some of the other more specific questions inline.

Re: Use ReactJS to Build Native Apps

#153
Cool. I've always thought that the native view layer is better viewed analagously to how web developers tend to view the DOM: a low(ish)-level API upon which to build abstractions that better fit the domain.

Hopefully, we will come to view manual NSView slugging in the same way that we'd now view building a single page webapp entirely with jQuery.

Re: Use ReactJS to Build Native Apps

#154

Earlier quoted context omitted.

Amelius, I cannot reply to you directly for some reason. Anyway... So say you're rendering some long list of items. Because react is just plain JS (no templates!), you will map the array of items to components in your render. You give each item a key so that react can reconcile components across renders. If component with same key is returned from render next time then it's kept in the DOM (and any updates applied),…

Thanks a lot for this detailed explanation. If I get this clearly, then still: render() -> returns N items every time it is invoked And React will diff those N items against the DOM (using a key) every time an update is required. So, to me it appears that still O(N) amount of work has to be done every time something small changes in the list. This is not necessarily a bad thing. But here we assume that doing render()…

no, it doesn't compare to DOM, it compares to the last result of render - an important difference performance-wise. the DOM is many times slower to query than plain objects.

also remember big-O notation doesn't really capture the essence of the problem here. looping through and querying N DOM elements is probably orders of magnitude slower than doing the same with N objects in memory

Re: Use ReactJS to Build Native Apps

#155
post #78
post #75

Hi, I'm just reading through the ReactJS docs for the first time, and I found something peculiar. Let me explain. So, as I understand ReactJS invokes a render() method defined by the user (programmer), and the result of that is diff'ed to previous results of the same method, and as a result, the DOM is modified. I can understand this, but... The DOM is already incrementally rendered by the browser. That is, changes t…

DOM is stateful, whereas the render() method is stateless. For instance, if you add a to the DOM, it will stay there forever. On the other hand if the next call to render() no longer includes the then React will do the work of removing it from the DOM.

But then render() has to re-generate all the stuff over and over again, which could be slow.

Re: Use ReactJS to Build Native Apps

#156
post #71

Summary of what I can make out so far: * Write JS as usual. Write React as usual, but don't use the DOM JSX elements (or the React.DOM) factories - instead use the new 'NativeView' elements. * The code you write runs in a Javascript interpreter on the background thread. * The NativeView elements communicate transparently with a native server running on the main thread, which renders and fills native views based on th…

Has anyone asked if this can use other JS libs other than just React ones? Also, if it's just using say JavaScriptCore and rendering native, I assume this means speed limitations imposed by the lack of Nitro/etc on the UIWebView are moot?

Re: Use ReactJS to Build Native Apps

#157
post #78

Earlier quoted context omitted.

DOM is stateful, whereas the render() method is stateless. For instance, if you add a to the DOM, it will stay there forever. On the other hand if the next call to render() no longer includes the then React will do the work of removing it from the DOM.

But then render() has to re-generate all the stuff over and over again, which could be slow.

Right, this is where you need to look at benchmarks http://swannodette.github.io/2013/12/17/the-future-of-javasc...

Re: Use ReactJS to Build Native Apps

#160
post #124

I have long questioned the validity of middleware (for the lack of better terms, please don't be pedantic) to create native applications. I get it, HTML can replicate performance of native apps to a certain extent now, but it's also bound by restrictions that native apps aren't. Speed of innovation being one. HTML5 is a large ship that takes a long time to evolve (in comparison). iOS and Android aren't, by the same m…

What's the difference between this and websites competing with native Windows/Mac OS/Linux apps? Sure the performance isn't quite as good, but not being locked to a platform is a huge benefit.
Post reply on HN