Skip to content

Commit cc5498b

Browse files
Update interactionmanager.md
When it’s good to use / When not to use ++ Rule of Thumb
1 parent 7da01bc commit cc5498b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

docs/interactionmanager.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,41 @@ InteractionManager.runAfterInteractions(() => {
1515
});
1616
```
1717

18+
---
19+
20+
`InteractionManager` is great for certain cases, but if you use it everywhere you might make your app **feel slow or unresponsive**.
21+
22+
---
23+
24+
### ✅ When it’s *good* to use:
25+
26+
* **Heavy JS work that isn’t urgent**
27+
e.g., processing a large API response, sorting a big list, parsing JSON, etc.
28+
* **Tasks after screen transitions**
29+
e.g., preload non-critical data only after navigation animations finish.
30+
* **Low-priority UI updates**
31+
e.g., updating analytics, caching, saving drafts.
32+
33+
---
34+
35+
### ❌ When *not* to use:
36+
37+
* **Urgent actions that must happen immediately**
38+
e.g., validation feedback after pressing “Submit,” updating a counter in real-time.
39+
* **User input response**
40+
Delaying UI reaction to touches will make the app feel laggy.
41+
* **Short tasks (<1–2 ms)**
42+
The delay from waiting for animations might be longer than the task itself.
43+
44+
---
45+
46+
### 🔍 Rule of Thumb:
47+
48+
> If the task can wait **a few hundred ms** without hurting the user experience, `InteractionManager` is your friend.
49+
> If the task is essential for immediate feedback, run it right away.
50+
51+
---
52+
1853
Compare this to other scheduling alternatives:
1954

2055
- `requestAnimationFrame()` for code that animates a view over time.

0 commit comments

Comments
 (0)