RORK LABJP
MAX — Rork Max generates native Swift apps across iPhone, iPad, Watch, TV, Vision Pro, and iMessageNATIVE — It reaches AR/LiDAR scanning, Metal 3D games, widgets, Live Activities, and on-device Core MLFUNDING — Rork raised $2.8M from a16z, with 743K monthly visits and 85% growthPRICING — It's free to start, with paid plans beginning at $25 per monthFLOW — Describe your idea in plain English to get working code, a shareable test link, and iOS/Android buildsCOMPARE — The original Rork builds cross-platform apps on Expo/React Native; choose the right tool per goalMAX — Rork Max generates native Swift apps across iPhone, iPad, Watch, TV, Vision Pro, and iMessageNATIVE — It reaches AR/LiDAR scanning, Metal 3D games, widgets, Live Activities, and on-device Core MLFUNDING — Rork raised $2.8M from a16z, with 743K monthly visits and 85% growthPRICING — It's free to start, with paid plans beginning at $25 per monthFLOW — Describe your idea in plain English to get working code, a shareable test link, and iOS/Android buildsCOMPARE — The original Rork builds cross-platform apps on Expo/React Native; choose the right tool per goal
Articles/App Dev
App Dev/2026-06-27Intermediate

Your Animation Keeps Running After You Leave the Screen — Focus-Aware Battery Savings in a Rork (Expo) App

In a Rork-generated Expo app, a gradient or breathing animation can keep running after you push another screen or background the app, quietly draining the battery without ever surfacing as jank. The cause is that Reanimated's withRepeat lives on the UI thread and the navigation stack keeps screens mounted. This shows a lifecycle design — useIsFocused plus AppState — that reliably stops off-screen and background loops, with working code.

Rork463React Native188Expo115Animation6Performance21

Premium Article

While building a "breathing guide" for one of my calming apps, I added a slow gradient that gently expanded and contracted. I liked the look. Then one evening, after carrying a beta build around all day, the device felt faintly warm, and the battery breakdown put this app surprisingly high under "background activity."

What puzzled me was that it never showed up as jank. Scrolling was smooth and nothing felt wrong. Yet the breathing animation kept expanding and contracting on the UI thread even after I pushed into Settings, even after I returned home and locked the phone. A silent loop running where I couldn't see it — that was what drained the battery.

After running several wallpaper and calming apps as an indie developer, the lesson I keep relearning is that when an animation stops matters more for battery than how heavy it is. Here I'll share a lifecycle design, using a Rork-generated Expo app as the example, that reliably stops off-screen and background loops.

Why animations don't stop when you leave the screen

It's counterintuitive, but pushing another screen does not stop your animation. There are two reasons.

First, a React Navigation stack does not unmount the previous screen — it keeps it mounted. When you push a detail screen, the list screen beneath it is still alive, and any withRepeat loop there keeps spinning. Tab navigators are even more pronounced: switching tabs generally leaves every tab's screen mounted.

Second, Reanimated's withRepeat runs on the UI thread (in a worklet). Even when the JavaScript thread stops rendering, the UI-thread animation advances independently. That independence is what makes it smooth — but the flip side is that it keeps running in a place JS can't see.

And critically, this never registers as jank. A dropped frame means rendering couldn't keep up; this problem is the opposite — rendering is keeping up, faithfully drawing frames for a screen nobody is looking at. It won't appear in a profiler's hitch view; it only accumulates, quietly, in the Energy Log.

Does each technique auto-stop off-screen?

Before designing the stop logic, it speeds up your decisions to know whether the animation techniques your app uses stop on their own off-screen or not.

TechniqueAuto-stops off-screenHow to stop it
Reanimated withRepeatNoCall cancelAnimation explicitly
Animated (RN core) loopNoHold the ref and call .stop()
Lottie (lottie-react-native)NoCall pause() on the ref / drop autoPlay
expo-video / expo-avNoCall the player's pause()
CSS-style infinite loop (WebView)DependsStop or hide the WebView
Loop inside a FlatList cellPartly, via virtualizationGate per-cell on visibility

The takeaway is that most techniques don't stop unless you stop them. Only FlatList virtualization unmounts off-screen cells for you — but headers and parallax layers sit outside virtualization, so they're the exception.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Understand why withRepeat loops, Lottie, and video keep running off-screen — the navigation stack stays mounted and the UI thread runs independently — and stop them reliably by combining useIsFocused with AppState
Get the reset step that prevents cancelAnimation from freezing a value mid-way, plus the useFocusEffect cleanup pattern that avoids double-starting a loop
Know, per animation technique, whether it auto-stops off-screen, so you can target only the always-on loops — breathing animations and wallpaper previews — for pausing
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

App Dev2026-06-27
Before You Ask 'Are You Sure?' — Consider an Undoable Delete
Showing a confirmation dialog every time someone removes a list item trains them to tap OK without reading. Here is how to build an undoable delete in a Rork (Expo) app, and where confirmation dialogs still belong.
App Dev2026-06-27
Your Arabic Users See an Unmirrored Layout — RTL in a Rork (Expo) App and the Reload Trap
You added Arabic to a Rork-generated Expo app, but the screen never flips and the back button stays on the wrong side. The cause is that I18nManager.forceRTL requires a relaunch. This walks through detecting direction with expo-localization, applying it reliably with Updates.reloadAsync, swapping to marginStart, and mirroring only the arrows — all with working code.
App Dev2026-06-03
Unifying Onboarding Across Six Wallpaper Apps: What One Month of First-Day Retention Showed Me
I folded the onboarding flows of six wallpaper apps scaffolded with Rork into a single config-driven component and watched first-day retention and push opt-in for a month. Here is an honest, operational note on what moved and what didn't.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →