◉RORK LABJP
●GPT-6.1 SOL — Added to Rork's model menu (09-29) with Low, Medium and High effort; included on Pro and Max●SONNET 5.5 — Claude Sonnet 5.5 is selectable: strong at UI design and faster than Sonnet 5 (09-28)●SDK 58 — Beta since 09/15 with no stable date yet; running projects in Expo Go has required login since 09/03●WIDGET — A write-up traces an iOS widget that renders black only in production builds●OBSERVE — EAS Observe now records native crashes too (SDK 57.0.21 or later, 10/07)●NEW — My App Open Ad Only Showed When the App…●GPT-6.1 SOL — Added to Rork's model menu (09-29) with Low, Medium and High effort; included on Pro and Max●SONNET 5.5 — Claude Sonnet 5.5 is selectable: strong at UI design and faster than Sonnet 5 (09-28)●SDK 58 — Beta since 09/15 with no stable date yet; running projects in Expo Go has required login since 09/03●WIDGET — A write-up traces an iOS widget that renders black only in production builds●OBSERVE — EAS Observe now records native crashes too (SDK 57.0.21 or later, 10/07)●NEW — My App Open Ad Only Showed When the App…
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.

Rork585React Native239Expo219Animation8Performance25

✦ 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-08-16
My chart broke on day one, not at scale
A line chart that vanished for anyone with only a few days of data. The cause was a zero-height Y axis turning coordinates into NaN. Here is the measured behavior and the small normalization layer that fixed it.
◇ App Dev2026-08-06
Deciding overlay text legibility at ingest time instead of on device — four metrics measured side by side
Moving the question of whether text stays readable over a wallpaper out of the device and into the content pipeline. Four candidate metrics measured across 240 images, including what downscaled judging actually computes.
◇ App Dev2026-10-15
When adjustsFontSizeToFit Shrinks Just One Row, Suspect the Box Height, Not the String
Only the 10th row of a list drops to 4pt on iOS, though the data and strings are fine. I read the Yoga rounding and font-fit sources, then counted how often the box comes up short in Node.