~/swaraj.dev
Back to all posts
June 5, 20261 min read

Deferring Heavy Work with InteractionManager to Keep UI Fluid

Learn how to use React Native's InteractionManager to postpone expensive calculations until after UI interactions, preventing frame drops and jank.

react-nativeperformanceinteractionmanager

Insight

When a component triggers a costly operation—like parsing a large JSON payload or calculating layout—doing it immediately can block the UI thread and cause noticeable jank. React Native's InteractionManager lets you schedule such work to run after all ongoing interactions (animations, gestures, navigation transitions) have finished. This keeps animations smooth and preserves a responsive feel, especially on lower‑end devices.

Example

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

export default function HeavyList() {
  const [data, setData] = useState<string[]>([]);

  useEffect(() => {
    // Defer heavy parsing until UI is idle
    InteractionManager.runAfterInteractions(() => {
      const raw = '["apple","banana","cherry"]'; // imagine a huge payload
      setData(JSON.parse(raw));
    });
  }, []);

  return data.map(item => <Item key={item} title={item} />);
}

Takeaway

Wrap any non‑essential, CPU‑intensive logic in InteractionManager.runAfterInteractions to let the UI finish its current work first. This simple pattern dramatically reduces frame drops during navigation or animation sequences without adding extra libraries.