Intro
์ค๋์ ์ด์ ์ ์ด์ด ๋ฆฌ์กํธ ๋ค์ดํฐ๋ธ์ ๋ ๋ค์ํ ์ปดํฌ๋ํธ๋ค์ ์์๋ณด๊ณ ์ค์ตํด ๋ณด์๋ค.
์ค๋ ํ์ตํ ๋ด์ฉ
FlatList
: ๋์ฉ๋ ๋ฐ์ดํฐ๋ฅผ ํ ๋ฒ์ ์ฒ๋ฆฌํ ์ ์๋ ์ปดํฌ๋ํธ
๋จ์ ์ผ๋ก๋ ๋์ ๋ฐ์ดํฐ ์ฒ๋ฆฌ์ ๋ ๋๋ง์ด ๋ง์ด ํ์ํ๊ณ ๋ถ๋ชจ ์ปดํฌ๋ํธ๊ฐ ๋ ๋๋ง ๋ ๋ FlatList๋ ๋ฆฌ๋ ๋๋ง ๋๋ค๋ ์ ์ด ์๋ค.
๊ทธ๋์ ๋ณดํต useCallback์ผ๋ก ์ฒ๋ฆฌํ๋ค.
<FlatList
data={dummy_data}
renderItem={({item, index}) =>
<TestTemplate data={item} />
}
keyExtractor={item => item.id}
ListHeaderComponent={() => (
<View style={styles.chatDayWrapper}>
<Text style={styles.chatDay}>2022๋
2์ 7์ผ</Text>
</View>
)}
showsVerticalScrollIndicator={false}
/>
โ iOS ์๋ฎฌ๋ ์ดํฐ์์ ๋ฆฌ์กํธ ๋ค์ดํฐ๋ธ ๋๋ฒ๊น ์ฌ๋ ๋ฒ
โซ๏ธ Flipper ์ค์น (
โซ๏ธ ์๋ฎฌ๋ ์ดํฐ์์ Cmd โ+ D→ open debugger
์ธํฐ๋ ์ ์ ์ํ Animated
: ์๋๋ฉ์ด์ API
Props
- useNativeDriver: ์ฌ์ฉ ์ ์ฑ๋ฅ์ด ์ฌ๋ผ๊ฐ
- toValue
- duration: ์ซ์(ms) ๋์ ๋ณํจ
Func
- timing
- spring
- ...
React Navigation
Getting started | React Navigation
What follows within the Fundamentals section of this documentation is a tour of the most important aspects of React Navigation. It should cover enough for you to know how to build your typical small mobile application, and give you the background that you
reactnavigation.org
- ์ค์นํ๊ธฐ
npm install @react-navigation/native
npm install react-native-screens react-native-safe-area-context
- ํ์ํ Navigators ์ค์น
npm install @react-navigation/stack
npm install @react-navigation/bottom-tabs
...
- pod install
cd ios
npx pod-install
- ์ฌ์ฉํ๊ธฐ
: ํ์ด์ง์ props๋ก navigation ๊ฐ์ ธ์ค๊ฑฐ๋ useNavigation ์ฌ์ฉ
import React from 'react';
import { View } from 'react-native';
const Test = ({ navigation }) => {
return <View></View>
}
export default Test
import {useNavigation} from '@react-navigation/native';
const Test = () => {
const navigation = useNavigation();
...
}
Modal
: react naitve์ modal ๊ธฐ๋ณธ ์ปดํฌ๋ํธ๊ฐ ์์ผ๋ ์ปค์คํ ์ด ๋ฒ๊ฑฐ๋ก์ ์ ์ฌ์ฉํ์ง ์์
์ฃผ๋ก ์๋์ react-native-modal์ ์ฌ์ฉ
GitHub - react-native-modal/react-native-modal: An enhanced, animated, customizable Modal for React Native.
An enhanced, animated, customizable Modal for React Native. - react-native-modal/react-native-modal
github.com
import React from 'react';
import {View, TouchableOpacity, Text, StyleSheet} from 'react-native';
import Modal from 'react-native-modal';
const AlertModal = ({
isVisible,
okText,
noText,
headerTitle,
onPressOk,
onPressNo,
}) => {
return (
<Modal
useNativeDriver
animationOut="zoomIn"
animationOut="fadeOut"
animationInTiming={200}
animationOutTiming={200}
isVisible={isVisible}
backdropOpacity={0.6}
style={styles.modalContainer}>
<View style={styles.modalBox}>
<View style={styles.modalHeader}>
<Text>{headerTitle}</Text>
</View>
<View style={styles.modalButtonContainer}>
<TouchableOpacity onPress={onPressNo} style={styles.modalButton}>
<Text>{noText}</Text>
</TouchableOpacity>
<TouchableOpacity onPress={onPressOk} style={styles.modalButton}>
<Text>{okText}</Text>
</TouchableOpacity>
</View>
</View>
</Modal>
);
};
const styles = StyleSheet.create({
modalContainer: {
margin: 0,
justifyContent: 'center',
alignItems: 'center',
},
modalBox: {
width: 320,
borderRadius: 8,
backgroundColor: '#fff',
paddingTop: 10,
},
modalHeader: {
minHeight: 40,
justifyContent: 'center',
alignItems: 'center',
},
modalButtonContainer: {
flexDirection: 'row',
borderStyle: 'solid',
borderColor: '#c3c3c3',
borderTopWidth: 0.5,
},
modalButton: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
height: 50,
},
});
export default AlertModal;
๊ทธ ์ธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
Calendar
https://github.com/wix/react-native-calendars
GitHub - wix/react-native-calendars: React Native Calendar Components ๐๏ธ ๐
React Native Calendar Components ๐๏ธ ๐ . Contribute to wix/react-native-calendars development by creating an account on GitHub.
github.com
Slider
https://github.com/meliorence/react-native-snap-carousel
GitHub - meliorence/react-native-snap-carousel: Swiper/carousel component for React Native featuring previews, multiple layouts,
Swiper/carousel component for React Native featuring previews, multiple layouts, parallax images, performant handling of huge numbers of items, and more. Compatible with Android & iOS. - melior...
github.com
๋ง๋ฌด๋ฆฌ
๊ธฐ๋ณธ ์ปดํฌ๋ํธ๋ณด๋ค ์ฝ๊ฐ ์ด๋ ค์์ ธ์ ๊ณ์ ๋ง๋ค์ด๋ณด๊ณ ์ต์ํด์ ธ์ผ๊ฒ ๋ค.