For AI agents: the complete documentation index is available at /2.x/llms.txt, the full documentation bundle is available at /2.x/llms-full.txt, and this page is available as Markdown at /2.x/guide/usage/gesture-viewer-state.md.
v3 is stable. See what changed
  • English
  • 2.x
  • GestureViewer State

    GestureViewer provides a state management system to track the current state of the viewer. You can use the useGestureViewerState hook to access the state of the viewer.

    useGestureViewerState

    import { GestureViewer, useGestureViewerState } from 'react-native-gesture-image-viewer';
    
    function App() {
      const { currentIndex, totalCount } = useGestureViewerState();
    
      return (
        <View>
          <GestureViewer data={images} renderItem={renderImage} />
          <View>
            <Text>{`${currentIndex + 1} / ${totalCount}`}</Text>
          </View>
        </View>
      );
    }

    Parameters

    • id?: string
      • The ID of the GestureViewer instance.
      • Default: "default"

    API Reference

    PropertyDescriptionTypeDefault Value
    currentIndexThe index of the currently displayed item.number0
    totalCountThe total number of items.number0