Skip to content

Instantly share code, notes, and snippets.

@SwarajDashDev
Created May 30, 2026 04:45
Show Gist options
  • Select an option

  • Save SwarajDashDev/92d0d9df1bb615590aa0f0109d773e25 to your computer and use it in GitHub Desktop.

Select an option

Save SwarajDashDev/92d0d9df1bb615590aa0f0109d773e25 to your computer and use it in GitHub Desktop.
Learn how to keep animations buttery‑smooth by offloading expensive calculations to InteractionManager, ensuring they run only after the UI settles.

Insight

When a screen transition or animation starts, any synchronous JavaScript work can block the UI thread, causing jank. React Native's InteractionManager lets you schedule heavy tasks to run after all ongoing interactions finish. This is perfect for things like data parsing, image processing, or heavy state updates that aren't needed until the user can actually see the result.

Example

import { InteractionManager, useEffect, useState } from 'react';
import { View, Text, ActivityIndicator } from 'react-native';

export default function ProfileScreen() {
  const [profile, setProfile] = useState(null);

  useEffect(() => {
    const task = InteractionManager.runAfterInteractions(() => {
      // Simulate expensive parsing
      const data = JSON.parse(largeJsonString);
      setProfile(data);
    });
    return () => task.cancel();
  }, []);

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      {profile ? <Text>{profile.name}</Text> : <ActivityIndicator />}
    </View>
  );
}

Takeaway

Wrap non‑essential, CPU‑intensive work in InteractionManager.runAfterInteractions to let animations finish first. This tiny change can turn a jittery transition into a seamless experience without changing your app's architecture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment