Skip to content

· react native · 6 min read

5 Tips to Solve Common Pitfalls With React Native

Common issues I encountered when building mobile apps with React Native and how I solved them

Neciu Dan

Neciu Dan

Hi there, it's Dan, Senior Engineering Manager at Perk, host of Señors at Scale - a podcast for Senior Engineers, Organizer of ReactJS Barcelona meetup, and international speaker, I'm here to share insights on combining technology and education to solve real problems.

I write about startup challenges, tech innovations, and the Frontend Development. Subscribe to join me on this journey of transforming education through technology. Want to discuss Tech, Frontend or Startup life? Let's connect.

Share:

The world of mobile development has expanded in recent years, going from being proprietary to Android and Swift developers to the fast pace world of Javascript with Hybrid Frameworks like Ionic or Native frameworks like React Native.

React Native is an open-source UI software framework created by Meta Platforms, Inc. It is used to develop applications for Android, Android TV, iOS, macOS, tvOS, Web, Windows and UWP by enabling developers to use the React framework along with native platform capabilities.

When using React Native, you might encounter issues that are difficult to solve or find an answer to, mostly because the React Native community and ecosystem are not as big as other Javascript communities like React or Vue.

In this article, you will learn from my experience of how I solved some common React Native issues or implemented some tricky features.

1. Apple Connect Store Screenshots

Apple Store Review Process When building apps with React Native you might be using a simulator to test your apps, rather than a physical device.

Like me, you might be surprised how difficult is to use Xcode Simulator to create the screenshots of the right size and density for the App Store.

In Google Play the process was straightforward and uploading screenshots you made in any simulator worked great, but for the Apple store, I could not get the dimensions right.

For a 6.5’’ iPhone they were asking for either 2688x1242 or 2778x1284. I tried all sorts of options and device emulators to achieve this … but with no success. Finally, I found the correct answer here.

Here is what you have to do:

  • Set simulator to physical size: Window > Physical Size (Shortcut: command + 1)
  • Set High-Quality Graphics: Debug > Graphics Quality Override > High Quality
  • For a 6.5’’ iPhone use any Pro iPhone. I used 11 Pro
  • For 5.5’’ iPhone use iPhone 8+ simulator.
  • For Ipad Pro (3rd / 2nd gen) use Simulator iPad Pro (12.9-inch) (3rd generation)

2. The trouble with Fonts

By default React Native uses the standard font for each platform, which means ‘Roboto’ for Android and ‘San Francisco’ for iOS. Designers, however, usually like to use different fonts that fit the overall design of the app.

If you are lucky and the font is a Google Font, that’s great! You can use the package expo-google-fonts.

After installing the package, expo install expo-google-fonts , all you have to do is this:

Adding google fonts

Here we are importing the fonts and making sure they are loaded before starting the app, then you can easily use it in your stylesheet like this:

fontFamily: 'Lato_400Regular'

One issue that I had with expo-google-fonts was when I imported by mistake the entire project, which loaded all the fonts, and not just the Lato font, like this:

import { Lato_400Regular } from '@expo-google-fonts/dev';

This will work without problems on web-view, or in the Android simulator, but for iPhones, it will try to load all the fonts at once and it will crash the app because of memory limits.

So make sure you are importing only the fonts you need like this:

import { Lato_400Regular } from '@expo-google-fonts/lato'; 

3. Local Storage and Cookies on Mobile Devices

Having a Front End programming background, I’m used to abusing cookies and local storage for almost anything.

Need to save some user information for later use? Cookies! What about this request that barely changes … where can I cache it? Local Storage!

So here I was taking it for granted and adding my bearer token used for Authorization and User Information Object to Local Storage. Only when I started testing in emulators, did I realize that the token was not persisted and I was making every request with an empty Bearer string.

A quick internet search got me to the most used package in this situation: react-native-async-storage/async-storage.

After installing the package, expo install react-native-async-storage/async-storage using it is as easy as normal local storage.

Using the package

Pay close attention to JSON.stringify() and JSON.parse() functions. If you try to pass JSON instead of a string to the AsyncStorage.setItem() function, your app again is going to work on the web and even in the simulator but it will break in production and crash your app.

And debugging this issue can be quite troublesome, so having a quick check to stringify and parse by default can become good practice and save you from pain in the future.

4. Rendering HTML

Html Example

You can hardcode texts in your application, but then whenever you want to change a text you have to go through the process of creating new builds for your app and submitting it on the app store again.

Worse, some users may have automatic updates disabled for your app and will never get the new version. To overcome this, you should always send your not-common texts through the API.

But even if you send your text through some request, what about dynamic content? What if you have articles or content with rich descriptions. In your backend, you may have a rich text editor so you can add headings and format your text to your desire, but in the app, you need a way to render that HTML into native Views.

Render HTML example

To accomplish this you can use react-native-render-html. An iOS/Android pure javascript react-native component that renders your HTML into 100% native views.

Using it is very straightforward. It also has a prop to inject your fonts called systemFonts, as seen above.

The tagStyles prop can be used to style the HTML content. Here is a short demo to see it in action.

5. Short-circuit evaluations (&&)

One of my blunders coming from the React Ecosystem was my over-attachment to the && operator when rendering components.

{isFetching && <Loading />}

And this worked great until I made the mistake of using non-Boolean values as the first operand like this:

{users.length && <User />}

This worked great in normal React and did not break at all in the web view of the project, worse yet it also worked on emulators for Android and iOS.

But in Production whenever a user entered a View with this kind of logic the app crashed with this error:

Error: Text strings must be rendered within a <Text> component.

This makes sense, if your users array was bigger than 0, React Native wanted to render the number and because it wasn’t in a component it would break the app.

I recommend being careful when using the logical operator && to shortcut rendering, especially when dealing with non-string values.

For now, the React Native community is growing, there are a lot of good packages out there to help you on your journey.

But it has not yet reached Javascript levels of fame, which you can tell by the number of resources available to you.

I sincerely hope this article helps aspiring React Native developers with their struggles or convinces engineers from the React ecosystem to try it out and build a couple of mobile apps.

Neciu Dan

Discover more from The Neciu Dan Newsletter

A weekly column on Tech & Education, startup building and occasional hot takes.

Over 1,000 subscribers

🎙️ Latest Podcast Episodes

Dive deeper with conversations from senior engineers about scaling applications, teams, and careers.

Hypermedia at Scale with Carson Gross
Episode 53
58 minutes

Señors @ Scale host Neciu Dan sits down with Carson Gross, creator of HTMX, principal at Big Sky Software, and computer science professor at Montana State University. Carson has been programming for more than 30 years, from HyperCard on a family Mac to Excel macros for an industrial engineering firm, a JVM language called Gosu, a Rails startup, and the 2012 library Intercooler.js that he rewrote without jQuery during COVID and released as HTMX. His argument is that the web was built as a hypermedia system, that links and forms are control logic living inside the document, and that most of what we call REST today fails the one constraint Roy Fielding cared about. He also covers which apps HTMX is wrong for, what changed in HTMX 4 and why 3 was skipped, and why his students now sit pencil and paper exams. It is a conversation about using the browser as the hypermedia client it was built to be.

📖 Read Takeaways
Performance at Scale with Ryan Townsend
Episode 52
52 minutes

Señors @ Scale host Neciu Dan sits down with Ryan Townsend, Principal Product Manager for Performance at Cloudflare, where he owns real user monitoring and the wider performance measurement remit. Ryan has over 20 years in web technology and a decade as a CTO: he co-founded Shift Commerce, the first enterprise scale headless SaaS, and was CTO of Matalan Direct after the business he built came second in Shopify's Build a Business competition with only three months of trading. We cover why the 'Rails doesn't scale' story was always a myth, the resume driven development he kept finding as a fractional CTO, the personalization script that claimed zero performance impact and cost seconds at P90, and how Shift ran over 99% cache hit ratios by splitting the anonymous page from the basket.

📖 Read Takeaways
Design Systems at Scale with Szymon Chudy
Episode 51
56 minutes

Señors @ Scale host Neciu Dan sits down with Szymon Chudy, Software Engineer at Netflix on the Hawkins team, which builds the design system behind thousands of internal applications used to produce the shows you watch. Before Netflix, Szymon spent two and a half years at Lokalise, growing from senior to staff frontend engineer and leading frontend direction across teams, and before that he toured Poland as a reggae guitarist while freelancing as a web developer in the off season. From why the source of truth for a design system lives in code, to Hawkins Consumer versus Hawkins Professional, to the UI paved road that changes what freedom and responsibility mean at Netflix, to measuring the team on adoption rate and shipping codemods and agent skills for every breaking change, to what being an informed captain who farms for dissent means in practice, this is the design system conversation for anyone maintaining a platform other engineers have to choose to use.

📖 Read Takeaways
Agentic Systems at Scale with Vilva Athiban
Episode 50
52 minutes

Señors @ Scale host Neciu Dan sits down with Vilva Athiban, Lead AI Engineer at Omio, one of Europe's leading travel platforms, where he architects and ships agentic AI systems in production. Vilva designed and delivered Omio AI, along with the MCP integrations that connect AI agents to the company's systems. He never set out to switch from JavaScript to AI: in June 2024 Omio picked two people to start an AI team reporting to the CEO and CTO, and he learned on the job, from his first API call to an LLM up to a consumer-facing agent whose backend runs on nothing but MCP. From why a bigger model with medium thinking came out cheaper than the mini, to capping tool calls because LLMs are built for token maxing, to the whale hunting request that showed his team guardrails are subjective, this is a conversation about what production agentic systems look like once the tutorials run out.

📖 Read Takeaways
Back to Blog