API

Transition Blocking

Use blockTransition and unblockTransition to control when a pending transition starts.

blockTransition() holds a screen's pending lifecycle transition at its initial frame. unblockTransition() releases one block.

TSX

1import {
2 blockTransition,
3 unblockTransition,
4} from "react-native-screen-transitions";
5
6async function prepareForTransition(routeKey: string) {
7 blockTransition(routeKey);
8
9 try {
10 await prepareDestination();
11 } finally {
12 unblockTransition(routeKey);
13 }
14}

Calls are reference-counted per route. Pair every block with one unblock for the same route. When routeKey is omitted, both functions resolve the most recently focused screen in navigation history.

Blocking changes when the animation starts. It does not reduce JavaScript work or move rendering to another thread.