Hey there, fellow developers! Wondering if React Native can hold its own against the performance challenges in today’s competitive mobile app landscape? We’ve got some exciting news for you. In this article, we’re going to dive deep into React Native’s brand-new architecture. We’ll break down the geeky bits and show you how it tackles those pesky performance concerns that have been holding it back. Let’s roll!
The Past in a Nutshell
So, we’re all familiar with the old way React Native worked, right? It leaned heavily on this thing called the “bridge” – a sort of translator between JavaScript and native code. It sounded good on paper, promoting code reusability, but it ended up causing delays due to all the translation back and forth. This showed up in animations, UI interactions, and anything that required snappy responsiveness.
The Big Transformation
But hold onto your hats, because React Native has taken a leap forward with its new architecture. Think of it as a major upgrade that’s turbocharging the whole experience. We’re talking about a triple combo of tech goodness: Fabric, Turbo Modules, and JavaScript Interface (JSI). Let’s unravel this superhero trio and see how it’s changing the game.
Smooth Multitasking with Threads
In the old days, React Native had all its JavaScript running on one thread. Not ideal when you’re juggling a ton of tasks, right? The new architecture, thanks to Fabric, spreads the workload across multiple threads. This means your app can handle more without getting bogged down, giving users a smoother ride.
Snappy UI Updates
Ever wished you could just update the bits of your app that need fixing, instead of redoing the entire UI? With the new architecture, you totally can. React Native now updates only the parts that need it, making your app faster and more efficient at handling changes.
Animations that Pop
Animations are like the spice of mobile apps, but the old architecture often left them feeling a bit bland. Not anymore. The new setup uses multithreading and smart rendering, making animations buttery smooth.
Meet Fabric, Your UI Wingman
Now, let’s talk about Fabric. It’s like a secret weapon that React Native has brought in. Fabric takes care of how your app’s user interface is handled, using clever tricks like asynchronous layout and rendering. This means your app’s interface gets a makeover for speed and performance without breaking a sweat.
Turbo-Charging Modules
Here comes Turbo Modules, swooping in to give your app a turbo boost. It optimizes how your app’s JavaScript talks to the native code, cutting down startup times and reducing memory hogging. It’s like switching to a supercharged engine for your app.
JSI – Making Friends with Native
JavaScript Interface, or JSI, is like the cool bridge replacement that React Native was waiting for. It enables direct talk between JavaScript and native code, ditching the translation process. The result? Faster app launches, smoother interactions, and memory that behaves itself.
Smarter Rendering for Crisp UI
Fabric introduces a smarter way of updating UI components. Now, only the parts that really need to be updated get refreshed. No more unnecessary work, meaning your app feels more responsive without overloading your device’s brain.
Rock-Solid Interactions
Fabric isn’t just about looks, though. It’s got the brains to back it up. Even when your app is dealing with complex tasks, Fabric keeps interactions smooth and responsive. Say goodbye to those annoying jitters and stutters.
Performance Breakthrough & Numbers
So, all these buzzwords sound impressive, but does the new architecture really deliver? For that, let’s delve into the performance statistics, as provided by the React Native team. These concrete numbers paint a vivid picture of the improvements brought by the new architecture.
On Google Pixel 4, for example:
- In scenarios involving 1500 View components, the old architecture took 282ms, while the new architecture significantly reduced it to 258ms, marking an approximate 8% performance boost.
- Scaling up to 5000 View components, the old architecture clocked in at 1088ms, while the new architecture impressed with a more efficient 1045ms, representing a noticeable 4% improvement.
- For 1500 Text components, the old architecture took 512ms, whereas the new architecture edged ahead at 505ms, achieving approximately 1% better performance.
- With 5000 Text components, the old architecture required 2156ms, while the new architecture delivered a more responsive 2089ms, marking an approximately 3% improvement.
- When it comes to 1500 Image components, both architectures performed similarly, with the new architecture staying on par with the old.
- However, scaling up to 5000 Image components, the old architecture took 1414ms, while the new architecture showed a noteworthy 3% improvement, concluding at 1370ms.
And on the iPhone 12 Pro:
- For 1500 View components, the old architecture demonstrated a performance of 137ms, while the new architecture sprinted ahead with a brisk 117ms, marking an impressive 15% performance gain.
- Scaling up to 5000 View components, the old architecture clocked in at 435ms, while the new architecture impressively completed the task in just 266ms, achieving a remarkable 39% performance improvement.
- 1500 Text components also experienced a substantial performance boost. The old architecture took 324ms, while the new architecture sprinted ahead at 284ms, marking a 13% improvement.
- For 5000 Text components, the old architecture demanded 1009ms, while the new architecture demonstrated an impressive 20% improvement, finishing at 808ms.
- The performance gap was further evident with 1500 Image components. The old architecture took 212ms, while the new architecture showed a 19% performance gain, finishing at 172ms.
- When scaling up to 5000 Image components, the old architecture took 673ms, whereas the new architecture zoomed past with a remarkable 33% performance improvement, concluding at 451ms.
The new architecture also significantly reduces the overall app size and application start-up.
These performance metrics are a testament to the new architecture’s ability to significantly boost speed and responsiveness across various scenarios, making it an enticing choice for building your next-generation mobile apps.
Embrace the Future
With Fabric, Turbo Modules, and JSI in the mix, React Native has risen to the challenge. It’s like a shiny, new sports car that handles like a dream. The architecture that was once questioned for its performance now stands strong, ready to give you an edge in the ever-competitive app race. So, don’t be hesitant – dive in and harness the potential of React Native’s latest architectural marvel. Your app’s speed, performance, and user experience will thank you for it!
References
The New Architecture Performance Benchmarks
Experiment With the New Architecture of React Native
I Tested React Native’s New Architecture Improvements So You Don’t Have To
How the React Native Bridge works (and how it will change in the future)
How react-native became performant as native with the new architecture
.……………..
From concept to deployment, Gurzu provides an end-to-end mobile development solution. Our application development prioritizes intuitive interfaces, seamless user experiences, and robust functionality.
Are you looking to empower your business through user-centric mobile solution? Reach out to us for a free consulting call!
This article is based on a talk by Kiran about Bloc Pattern. Get the slide deck here.
You might also want to read “Adding Chat to a React Native App with Firebase” here