Overview
TheuseScreenState hook provides access to navigation state, screen information, and stack context without animation values. Use this hook when you need to access route information, screen index, or navigation object without triggering animations.
Import
Usage
Return Value
Returns aScreenState object with the following properties:
The index of this screen in the stack (0-based).
Index of the currently focused (topmost) screen in the stack.
Route object of the currently focused screen in the stack.Properties:
key(string): Unique key for this routename(string): Route nameparams(object): Route parameters
Array of all routes currently in the stack.
Screen options for the currently focused screen, including all transition configuration.
Navigation object for this screen. Provides methods like
navigate(), goBack(), push(), etc.Custom metadata from the focused screen’s options. Use this to pass custom data between screens.
Programmatically snap the focused screen to a snap point index. Only works if the screen has
snapPoints configured.Scoped to this screen’s stack context, avoiding global history ambiguity.Examples
Display Stack Position
Access Route Parameters
Control Snap Points
Conditional Rendering Based on Stack
Use Custom Metadata
Navigate with Stack Context
TypeScript
You can type the navigation object by passing a generic parameter:Notes
Use
useScreenState when you need navigation state without triggering animations. For animated values, use useScreenAnimation instead.The
snapTo function is scoped to the current stack context, so it will only work for screens in the same stack.The
meta property is useful for passing custom configuration between screens without polluting route params. It’s also accessible in screenStyleInterpolator for conditional animation logic.Related
- useScreenAnimation - Access animation state and interpolation props
- useHistory - Access navigation history across the app
- Snap Points - Learn more about using snap points
