r/reactnative • • Apr 18 '20

The React Native 10 commandments

  1. Thou shalt never upgrade a react native version without at least having 72 hours of dedicated time.

  2. When you can't figure out what's wrong then delete node_modules, delete Pods, delete DerivedData, delete cache, and rebuild everything.

  3. Something running perfectly on ios has a 50% chance of being laggy on android.

  4. Every library added to your project will break your build at some point in the future.

  5. Never install a library that hasn't been updated in the last 6 3 months.

  6. The answer to your question is in a closed github issue.

  7. Don't be afraid to get into the native code and make changes.

  8. Native code is a frightening place, only make changes as a last resort.

  9. If you close your eyes before running a build command it has a 25% higher chance of building successfully.

  10. All changes made to the native build systems will be forgotten until it breaks your build at a later date.

385 Upvotes

55 comments sorted by

12

u/Tayk5 Apr 18 '20

Oh man, this makes me concerned about choosing to learn RN over Flutter. Are there any Flutter devs here willing to share your Flutter experiences versus RN?

7

u/richpeopleshit Apr 18 '20

Don’t worry, I actually really enjoy working in React native!

10

u/ncuillery Apr 19 '20 edited Apr 19 '20

I work with RN for 4 years, then switch to Flutter these past 6 months. My honest opinion is: Flutter is superior on every aspect. Expect maybe the syntax (I miss JSX a lot), but navigation, integration testing, hot reload,... are way better in Flutter.

I lost faith in RN upgrade after upgrade... Point 1 to point 6 are the damn truth, even for a experienced dev like me.

Oh, and Dart offers a very similar experience as JavaScript + TypeScript except it's built-in into the language. So no library with unsync or inexistant type definitions...

2

u/drink_with_me_to_day Apr 19 '20

Flutter = Flash

1

u/ncuillery Apr 19 '20

Hmmm, not sure what you mean

4

u/drink_with_me_to_day Apr 19 '20

Since Flutter renders everything with its own engine, it's analogous to Flash.

Or similar to releasing an UI framework for Unity. Or Adobe Air. It's just painting everything on it's own.

4

u/verylevelheaded Apr 20 '20 edited Apr 20 '20

I like that it is painting everything. You actually have one codebase and not one pointing to two other underlying codebases. The Flutter apps I've been downloading are night and day better feeling/performance wise.

1

u/drink_with_me_to_day Apr 20 '20

Well, that brings with it a slew of different issues that you might not face, but when you do you can't fix them and they won't be fixed.

There are always tradeoffs

6

u/red_arma Apr 19 '20

Wrote my bachelors thesis about building enterprise level apps with both frameworks. They are almost the same and in the end React Native won due to its maturity. For Flutter A LOT is still missing and if you find a package thats bringing a feature that you rely on its made by some small third party company or even just 1 dev and he/they have zero obligation to keep this repository/package updated and fixed for every single update there is. For me its React Native all the way, while Flutter has a much better documentation and workflow/learning curve, while React Native has a older/more mature community with much more packages at hand.
You can use cross-platform development to such an extend that its as good as native development (just embed native code if needed at certain points, just like Instagram), but comparing between cross-platform frameworks themselves, React Native is still ahead. That might look different in 1,5 - 2 years from now.

1

u/Tayk5 Apr 19 '20

Thanks for the breakdown. That helps! I still love the idea of React for mobile development as I can reuse all my state management and programming best practices. I'm hoping I won't hit a roadblock where my apps no longer work or can't be updated. Like you've said RN has a mature community who have already had to solve 99.99% of the issues I'd face.

1

u/rusl1 Apr 19 '20

I used to think that Flutter is a huge joke so I started using React and React Native for many months but in the last two weeks a spent my time on Flutter and god it is just a pleasure to work with it compare to React. The developing experience is way better than RN, libraries are better organized and supported in my opinion, it just works!

0

u/moneckew Apr 18 '20

Bruh, RN is the way. Amazing framework. Look at my app: https://moodflow.co

1

u/pelanggan Apr 19 '20

Wow look awesome man. How do you play video as the background of your screen like that? Looks super cool and performant

2

u/moneckew Apr 19 '20

People who say Flutter is the way clearly haven't spent enough time on RN. RN is easy to learn, specially if you come from webdev like me. Creating layouts is a breeze.

For the Video background just put a Video element with position absolute and zIndex: -1.

For performance make sure to enable Hermes as your JS engine. This has significantly sped up my app. As well as requiring Components as needed and not on app start using Inline Requires.

1

u/more-food-plz Apr 20 '20

They’re both useful and each with its own advantages

1

u/moneckew Apr 20 '20

Yeah sure, RN however has more support and is more mature.

1

u/asharpvan Apr 19 '20

If i may ask. What framework are you using for the charts?

1

u/moneckew Apr 19 '20

The one shown on the website is custom made and I use some react-native-svg-charts for showing pies

1

u/asharpvan Apr 20 '20

Alright. Ill go through the same. Thanks!

5

u/richpeopleshit Apr 18 '20

They are not etched in stone yet so I'm open to any suggestions :)

2

u/[deleted] Apr 18 '20

number 1 is the holy grail for me... switched to flutter and been having a better experience there...

1

u/kbcool iOS & Android Apr 19 '20

Even minor version updates of third party libraries are guaranteed to break API contracts. Although I think this is a universal law with JavaScript.

52

u/getinnocuous21 Apr 18 '20

this is too accurate. and i've only been using RN for about 2 weeks

10

u/dandmcd Apr 19 '20

It never gets better. React Native is a miserable experience compared to normal React.

2

u/imjaadH Apr 20 '20

is a miserable experience compared to normal React.

for starters specially

1

u/Tayk5 Apr 19 '20

What did you experience exactly to make you dislike RN?

2

u/getinnocuous21 Apr 19 '20

in all fairness though, despite the odd issue i'm actually really enjoying it

1

u/FoxBearBear Apr 19 '20

I’m on react for about 2 weeks too and native for 2 days. Yesterday I spent some time debuting the code and it was not working because I used “ ” instead of ‘ ‘

1

u/mcfliermeyer Apr 19 '20

Wtf. Is this really a thing?

1

u/[deleted] Apr 22 '20

no. it isnt. Not in js code anyway.

1

u/[deleted] Apr 23 '20

Yeah it is. ` is different then '/".

0

u/[deleted] Apr 18 '20

[deleted]

2

u/ieatcarrots Apr 18 '20

Nah, stability has gone way up in the last year.

15

u/time2van Apr 18 '20

Yeah, but only because there was only one direction to go....

13

u/hjhart Apr 18 '20

This is gold!

7

u/react_noob Apr 19 '20

Module not found: Can’t resolve ‘Gold’ in /app/node_modules/react-native

17

u/arndomor Apr 18 '20

All true, except the first one, the best(sometimes only) way to upgrade a minor version is to restart a new project from scratch and copy your code over.

90% of the stuff takes you 10% of the time compared to native. And 10% of the things that you can easily do in native land will take you 90% time to find an unmaintained package or create some native bridge yourself.

6

u/[deleted] Apr 19 '20

Yes, and fuck this fact in particular.

5

u/jonathanpwheat Apr 19 '20

I’m so glad I’m not the only one who upgrades this way

8

u/exosoul Apr 18 '20

Something running perfectly on ios has a 50% chance of being laggy completely broken on android.

3

u/rockpilp Apr 18 '20

Error messages will be useful and understandable almost 50% of the time. git bisect is often more helpful.

3

u/shawn2910 Apr 18 '20

Something running perfectly on the simulator has a higher chance of failing to build too been suffering with this for the last week

3

u/kahvekola Apr 19 '20

11. If you want to use IAP, don't start with expo :)

2

u/[deleted] Apr 18 '20

So much better these days though, holy moley

2

u/db-rb Apr 18 '20

Is their a repo for this so we can contribute?

2

u/atwarog Apr 24 '20

Building a project successfully, then coming back the next day, has a 50% chance of not building, even if no code was changed.

2

u/[deleted] Jul 12 '20

lol so true, just encountered a n.6 https://github.com/facebook/react-native/issues/27307 which required me to open this one: https://github.com/facebook/react-native/issues/29348

2

u/osoese Apr 18 '20

6. The answer to your question is in a closed github issue. => suggesting a solution that breaks rule 5. Never install a library that hasn't been updated in the last 6 3 months. and forces you to use something that => rule 4. Every library added to your project will break your build at some point in the future.

and ofc expo is gonna update with breaking changes three versions ago so your work around isnt on it and this will happen the moment your 6 months coding spree starts to work and the day after you were too tired to build it last night. (true story for me)

...but I still love react native and even expo and ...

as a solid work around

...browserify with local import

good post

1

u/Tayk5 Apr 18 '20

The library could have been updated within the last 3 months but it could have a closed issue where someone fixed your issue by changing a config file or some other thing.

1

u/thatbigfatdonut69 Apr 18 '20

Printing this and posting it on my desk! Thank you kind sir!

1

u/adrianwechner Apr 19 '20

Why is it that you cant upgrade tn version? Or how would you do it without copying code?

1

u/billcosbysbutt Apr 19 '20

I've never copied code into a new project to perform an upgrade. I've been maintaining the same project since 0.54.0 and had one issue when upgrading (I think to 0.60). Most times I have to wait for a dependency to update but I've never had to wait for more than a week or so.

I'm assuming people are making poor choices when adding dependencies. Most updates have been fine for me.

1

u/BodyBilders Apr 19 '20

I don't know why RN forces to use that Expo stuff.

1

u/ItTechBlogs Apr 20 '20

Good tips! Thanks for sharing.

1

u/[deleted] Apr 23 '20

I've found RN much more pleasant than React, because styling on a huge screen is hard. I don't have CSS skills.

But I find this list almost useless to me, although its probably funny/ sarcastic to a lot of other people.

  1. It took me 2 hours to upgrade to 0.62 from 0.61.5.

  2. Sure, but this is already recommended by RN

  3. Android is easier for me and prefer editing xml and gradle files instead of weirdly formatted XCode proprietary files. Yes, I have an android device.

  4. I did not know this. It might hit me in the future. But all libraries will break in the future if its not maintained: not if its maintained, e.g. https://github.com/airbnb/native-navigation

  5. I've installed old libraries that have worked just fine.

  6. Github issues are always a nice place to find problems, they could be closed or open though.

  7. Don't be afraid? its not about fear, its about skill and knowledge. If you want to change it, know what you're changing, just like anything.

  8. Doesn't this depend on what youre trying to achieve. Change native code IF you need to.

  9. ... thats just made up obviously.

  10. Not if you understand what youre doing. Also, isn't that the same will all code. Forget about it until it breaks or you need to make a change.