React Native Nuggets — episode #01
or: what learn-by-coding taught me
“React Native looks pretty legit”, I thought
And now… well, I’m still like you. I’m still struggling daily with this fantastic framework, but working full time on it for so long made me appreciate how fast and capable it is.
I learned right away that it is hard to keep up the pace with its releases and features, let alone if you never had to work on production-level mobile apps — like I did, back then: this is why, along the way, I took notes of small things that I would have really loved to be told when I started.
Small pieces of advice, few hints here and there to approach issues in certain ways, or suggestions on things to avoid ’cause those will bite back in the future.
Small nuggets, if you like😇
If you are experienced with React Native, probably, you’ll read these tips and be like “this is dumb, how could you not know XXX or YYY?”. But please, bear in mind that I’m writing them down to:
- help newbies like me to get better at coding
- get feedback on them (maybe there’s something I’ve completely misunderstood!)
Ok, with all these warnings and explanations out of the way, let get started!
Nugget #1: Don’t rush updating to latest versions
When I started developing RN, a new version of the framework was released every 2 weeks: it was quite easy to get stressed out — when the first basic version of my app was 3 screen on, I was already 2 versions behind 😱
Now, the pace is a bit slower (once a month) and the team keeps this document updated, to help you not blindly update and end up in situations like
“nothing is working anymore, how do I fix it?!?”
It is OK to take it slow. Remember to read the release notes of every package before updating it, it will save you A TON of time (all GitHub’s repos have a releases section, you can click on that and see the changelog, most times).
Nugget #2: Don’t misuse`react-native link`
From time to time, you will add a new lib, which in its README will require you to use the incredibly useful
react-native link command: never, please, never just run it on its own.
It will work without issues most times, but what it does is that it re-links every single package you have already linked; in rare cases, this will link twice the same package, and it will crash your app. So, yeah, always run
react-native link nameOfPackage (even if the README doesn’t say it explicitly).
Nugget #3: Trust the “Reload” feature… but not really
You have surely already used the classic #RNdev move🕺 of shaking your phone to bring up the dev menu, and then pressing the “Reload” button to refresh the app you are working on.
Doing it updates the app with the latest code, sure, but I’ve found out that until you change mode between “Debugger dev mode” and the “Standard dev mode” (sorry, couldn’t figure out better names) the packager doesn’t have to completely re-create the code it puts into your phone.
What does it mean for you? That you may not find out some red-screen level errors right away: there was a day when I was working heavily on UI coding for a RN app, and so from time to time I copy/pasted code. This led to style duplications, which guess what? Creates red-screen warnings; but since I wasn’t recreating the package completely, the next day BOOOM! I had like 20 duplications to fix because just “Reloading” wouldn’t catch them up 😰
So, yeah, just like in the old days of the “save every 5 minutes” mantra, now I live by the “close the terminal and
react-native run-android (at least) every 3hours” approach.
Did you already knew all of this? Do you have any nugget you’d like to share? Let me know in the comments, I’m always looking forward hearing fellow developers’ opinions!
I have 20+ nuggets left in my journal, so I’ll be writing this series for ~6 more articles (ep.2 is here!), consider following me here or on Twitter to be updated on next episodes.
And, as always,
Happy coding! 🤖