Hacker News new | ask | show | jobs
by cableshaft 3345 days ago
I have prior ios experience and was able to get the view side of React Native working without much problems, but once I started needing to store something on the device (especially trying to understand Redux and other similar solutions), I hit a pretty solid wall in my development and eventually put it on the backburner.

It looks like you might have been able to bypass this in your app, but if not, how did you approach that aspect of it?

2 comments

In this app I did not have to worry about that, but I can recommend https://github.com/sunnylqm/react-native-storage for dealing with storing on the device if you want to manually do things. I haven't built an app with React Native yet that does rely on local storage; however, with Redux and the redux-storage library it should be no problem

I do very much like Redux, but definitely that whole data flow layer can be intimidating. Wes Bos has a great free course on react / redux ( https://learnredux.com/ ) that can help that learning process, and there is the excellent courses on https://reacttraining.com/ if you are willing to invest a little bit of money on learning.

With all that said, you don't _need_ to use Redux or anything else to work with storing data. It might be a good idea to try manually storing with the aforementioned storage library just so you can get something working and feel like you're making progress; and then spending some time with Redux and (https://github.com/michaelcontento/redux-storage provides support for storing data with react native). Good luck!

You probably don't need Redux if it's just simple persistence of data.

The simplest option is just to read and write a blob of JSON using the AsyncStorage API: https://facebook.github.io/react-native/docs/asyncstorage.ht...

Another option you could try is Realm, which is commercial but has a free tier (even for commercial apps) and has a pretty simple API: https://news.realm.io/news/introducing-realm-react-native/

Another is the SQLite module which comes with Expo:

Docs: https://docs.expo.io/versions/v16.0.0/sdk/sqlite.html Example: https://github.com/expo/sqlite-example/blob/master/main.js

Okay cool. Good to know that you don't need to use Redux in conjunction with AsyncStorage. I also like SQLite, so I'll investigate that as well.

It'd be really nice if I get away without Redux. It was the main pain point I had with it, everything else was fairly smooth.

Highly recommend realm, works like a charm and has migrations too.
I'm sure it works great, but I dislike adding too many layers to my apps. I've been burned too many times by companies that have stopped supporting and moved on to something else, or disappeared, or haven't kept up with the latest iOS changes, or whatever, and I'm forced to migrate to a different solution, to let myself use these for my personal projects, where I have very limited time and energy.

Even using React Native is more than I'd normally do, but I don't see a better cross-platform option right now.