react-navigation

React Navigation | React Navigation

React Navigation은 React Native에서 화면 전환을 할 수 있도록 도와주는 라이브러리 입니다.

설치 & 사용

<aside> 💡 자세한 내용은 아래를 참고해주세요 https://reactnavigation.org/docs/getting-started/

</aside>

react-native-reanimated-carousel

https://github.com/dohooo/react-native-reanimated-carousel

설치 & 사용

  1. 관련 모듈을 설치해줍니다

    npm install react-native-reanimated-carousel@3.3.0
    expo install --npm react-native-reanimated react-native-gesture-handler
    
  2. babel.config.js 파일을 수정해줍니다

    module.exports = function (api) {
      api.cache(true);
      return {
    		...
        plugins: ["react-native-reanimated/plugin"],
      };
    };
    
  3. Babel 설정을 위해 Cache 초기화를 해줍니다

    # expo 서버 종료를 먼저 시킵니다
    expo start -c 
    
  4. Carousel을 import하여 사용합니다

    import Carousel from "react-native-reanimated-carousel";
    
    ...
    return (
    	...
    <Carousel
    	  data={banners}
    	  width={Dimensions.get("window").width}
    	  height={200}
    	  autoPlay={true}
    	  sliderWidth={Dimensions.get("window").width}
    	  itemWidth={Dimensions.get("window").width}
    	  itemHeight={200}
    	  renderItem={(obj) => {
    	    return (
    	      <TouchableOpacity
    	        onPress={() => {
    	          Alert.alert("배너 클릭");
    	        }}
    	      >
    	        <Image
    	          style={styles.bannerImage}
    	          source={{ uri: `${API_URL}/${obj.item.imageUrl}` }}
    	          resizeMode="contain"
    	        />
    	      </TouchableOpacity>
    	    );
    	  }}
    />
    	...
    )