For AI agents: the complete documentation index is available at https://react-native-gesture-image-viewer.pages.dev/1.x/ko/llms.txt, the full documentation bundle is available at https://react-native-gesture-image-viewer.pages.dev/1.x/ko/llms-full.txt, and this page is available as Markdown at https://react-native-gesture-image-viewer.pages.dev/1.x/ko/guide/performance-optimization-tips.md.
v3 정식 출시. 변경 사항 보기
  • 한국어
  • 1.x
  • 성능 최적화 팁

    renderItem 함수는 useCallback으로 감싸서 불필요한 리렌더링을 방지하세요.

    import { useCallback, useState } from 'react'; 
    import { ScrollView, Image, Modal } from 'react-native';
    import { GestureViewer } from 'react-native-gesture-image-viewer';
    
    function App() {
      const images = [...];
      const [visible, setVisible] = useState(false);
    
      const renderImage = useCallback((imageUrl: string) => {
        return <Image source={{ uri: imageUrl }} style={{ width: '100%', height: '100%' }} resizeMode="contain" />;
      }, []);
    
      return (
        <Modal visible={visible} onRequestClose={() => setVisible(false)}>
          <GestureViewer
            data={images}
            renderItem={renderImage}
            ListComponent={ScrollView}
            onDismiss={() => setVisible(false)}
          />
        </Modal>
      );
    }

    대용량 이미지의 경우 expo-image나 FastImage 사용을 권장합니다.

    import { ScrollView, Modal } from 'react-native';
    import { GestureViewer } from 'react-native-gesture-image-viewer';
    import { Image } from 'expo-image'; 
    
    function App() {
      const images = [...];
      const [visible, setVisible] = useState(false);
    
      const renderImage = useCallback((imageUrl: string) => {
        return <Image source={{ uri: imageUrl }} style={{ width: '100%', height: '100%' }} contentFit="contain" />; 
      }, []);
    
      return (
        <Modal visible={visible} onRequestClose={() => setVisible(false)}>
          <GestureViewer
            data={images}
            renderItem={renderImage}
            ListComponent={ScrollView}
            onDismiss={() => setVisible(false)}
          />
        </Modal>
      );
    }

    많은 수의 이미지를 다룰 때는 FlashList 사용을 권장합니다.

    import { useCallback, useState } from 'react';
    import { Image, Modal } from 'react-native';
    import { GestureViewer } from 'react-native-gesture-image-viewer';
    import { FlashList } from '@shopify/flash-list'; 
    
    function App() {
      const images = [...];
      const [visible, setVisible] = useState(false);
    
      const renderImage = useCallback((imageUrl: string) => {
        return <Image source={{ uri: imageUrl }} style={{ width: '100%', height: '100%' }} resizeMode="contain" />;
      }, []);
    
      return (
        <Modal visible={visible} onRequestClose={() => setVisible(false)}>
          <GestureViewer
            data={images}
            renderItem={renderImage}
            ListComponent={FlashList} 
            onDismiss={() => setVisible(false)}
          />
        </Modal>
      );
    }

    디바이스에서 테스트하세요. (시뮬레이터에서는 성능이 제한될 수 있습니다.)