Live data from Hacker News

One month with React Native

whitesmith.co

11–20 of 55 posts

Re: One month with React Native

#11
Great post. We have been building our native apps on React Native for about half a year now and it has been awesome. Completely agree with this whole article.

Related: I would highly recommend trying out/using Expo.io if you are new to React Native and just want to get something working incredibly fast/easy to "hack" around with. It's a fantastic wrapper around React Native to jumpstart the whole dev experience.

Re: One month with React Native

#13
post #10
post #8

I have been working on a large React Native project for several months now. It's great for quick prototyping but once we started doing heavy database stuff it got really slow, especially on Android. Of course we could have ported that part to native code, but that kind of defeats the purpose, doesn't it?

What database were you using and what bottlenecks did you run into? Curious as I have yet to work with dbs in React Native.

We are using SQLite. The performance bottleneck is not the database itself but conversion between the Java and JavaScript environments.

Re: One month with React Native

#14
post #8

I have been working on a large React Native project for several months now. It's great for quick prototyping but once we started doing heavy database stuff it got really slow, especially on Android. Of course we could have ported that part to native code, but that kind of defeats the purpose, doesn't it?

Assuming you don't do heavy work in the UI-loop: I find react-native's bridge memory-management on Android rather questionable: [0]

They make heavy use of structures in native memory for argument-passing between JavaScript and Java. Once again someone thought they could outperform the JVM with their C-skills. My critique was dismissed :-/

Even though I showed that giving up RN's native memory and just sending serialised Json-Strings on the Heap over the bridge is 50-100% faster (and doesn't interfere with GC, so it should have less lags as well): [1]

The image library they use, Fresco, does the same. There are many year-old bug-reports open regarding OutOfMemory-errors and crashes, and RN apps tend to get unstable with more images. My bug-report [2] was dismissed as well without proper explanation.

But: At least some guy or girl didn't have to give their custom code up for to the better JVM. scnr

I use Strings for arguments in production and it's faster, so maybe try that out. :)

[0] https://github.com/facebook/react-native/issues/8780

[1] https://github.com/facebook/react-native/issues/10504

[2] https://github.com/facebook/fresco/issues/1363

Re: One month with React Native

#15
post #8

I have been working on a large React Native project for several months now. It's great for quick prototyping but once we started doing heavy database stuff it got really slow, especially on Android. Of course we could have ported that part to native code, but that kind of defeats the purpose, doesn't it?

You're running a local db of some sort? I'd assume you'd always want your app to be a thin client and just fetch data via REST or RPC.

Re: One month with React Native

#16

> Next, plan your Redux store ahead. I feel like I made the mistake of overusing it. Almost every property of my app is managed by Redux and this results in large reducers and many many actions to control all that. It’s very important to figure if some prop will be needed outside a certain component or not and, if not, keep that inside that component. How can you possibly know _in advance_ if a prop will be needed ou…

>>> How can you possibly know _in advance_ if a prop will be needed outside a certain component (you haven't written yet) or not? This seems to imply a suggestion to completely architect the entire app (what components exist, how they relate) before you write much code. And then somehow being correct, even as you develop the app and add new features etc.

In engineering, that's what we call the design phase.

Re: One month with React Native

#17
post #15
post #8

I have been working on a large React Native project for several months now. It's great for quick prototyping but once we started doing heavy database stuff it got really slow, especially on Android. Of course we could have ported that part to native code, but that kind of defeats the purpose, doesn't it?

You're running a local db of some sort? I'd assume you'd always want your app to be a thin client and just fetch data via REST or RPC.

Our app is used by people working in remote areas without mobile/wifi reception. Therefore we maintain a local copy of the user's state.

Re: One month with React Native

#18
post #14
post #8

I have been working on a large React Native project for several months now. It's great for quick prototyping but once we started doing heavy database stuff it got really slow, especially on Android. Of course we could have ported that part to native code, but that kind of defeats the purpose, doesn't it?

Assuming you don't do heavy work in the UI-loop: I find react-native's bridge memory-management on Android rather questionable: [0] They make heavy use of structures in native memory for argument-passing between JavaScript and Java. Once again someone thought they could outperform the JVM with their C-skills. My critique was dismissed :-/ Even though I showed that giving up RN's native memory and just sending seriali…

While there is a vm of sorts on Android, there's no jvm. Is your comment about Android or the (traditional) jvm?

Re: One month with React Native

#19
post #10

Earlier quoted context omitted.

What database were you using and what bottlenecks did you run into? Curious as I have yet to work with dbs in React Native.

We are using SQLite. The performance bottleneck is not the database itself but conversion between the Java and JavaScript environments.

What was the size of the result set?

Have you tried appending '... LIMIT [OFFSET ]' to constrain the per-query result set to a reasonable size?

Re: One month with React Native

#20

> Next, plan your Redux store ahead. I feel like I made the mistake of overusing it. Almost every property of my app is managed by Redux and this results in large reducers and many many actions to control all that. It’s very important to figure if some prop will be needed outside a certain component or not and, if not, keep that inside that component. How can you possibly know _in advance_ if a prop will be needed ou…

Just draw what you're building on a piece of paper. That's going to force you to think through a lot of it. Amazing how few FE engineers will do this.
Post reply on HN