useBreathingExercise
Read the active breathing exercise timeline
- Stable unknown
- Release candidate since 1.16.1-rc.3
- Development since 1.16.1-dev.2111+9796905
useBreathingExercise() reads the nearest BreathingExerciseProvider context.
const { methodType, remainingTime, progress, roundData } =
useBreathingExercise();It returns BreathingExerciseContextType:
methods,repeat, andonFinish: the active configuration.progress: a ReanimatedSharedValue<number>from0to1.roundData: a Reanimated shared value containingmethod,animationProgress, and phaseremainingTime.remainingTime: the current phase's time remaining as React state, rounded up by the provider's reaction.methodType:"inhale","hold", or"exhale"for the current phase.
Use shared values inside Reanimated worklets. For normal React rendering, use methodType and remainingTime rather than reading .value during render.
The hook throws useBreathingExercise must be used within a BreathingExercise component when called outside the provider. The BreathingExercise compound component mounts the provider automatically; BreathingExerciseProvider is available for a custom consumer tree.
Last updated on
BreathingExerciseProvider
Provider for the breathing exercise timeline
BreathingExercise Component
The BreathingExercise component is the main compound component that provides a complete guided breathing exercise experience. It serves as both a container and a context provider, offering flexible composition through its sub-components.