React Native โ
ReactNative CLI ์ค์น ๋ฐ ํ๋ก์ ํธ ์์ฑ โ
npx @react-native-community/cli@latest init AwesomeProject- Vscode Terminal์ ์ ๋ช
๋ น์ด ์คํํ์ฌ ์ ํ๋ก์ ํธ ์์ฑ
File > Add Folder to Workspace์ ํ ํ ํ๋ก์ ํธ๋ฅผ ์ํฌ์คํ์ด์ค์ ์ถ๊ฐ
ํ๋ก์ ํธ ๋๋ ํ ๋ฆฌ๋ก ์ด๋ โ
cd /๊ฒฝ๋ก/ํ๋ก์ ํธํด๋- ์์ฑ๋ ํ๋ก์ ํธ ํด๋๋ก ์ด๋
๊ฐ๋ฐ ์๋ฒ ๋ฐ ์ฑ ์คํ โ
npm start- Metro ๋ฒ๋ค๋ฌ๋ฅผ ์์ (React Native์ JavaScript ๋ฒ๋ค๋ฌ)
- ์ฝ๋ ๋ณ๊ฒฝ ์ฌํญ์ ๊ฐ์งํ๊ณ ์๋์ผ๋ก ์ฑ์ ์๋ก๊ณ ์นจ
- ๋๋ฒ๊น ์ฝ์์ ์ ๊ณต
- ์ฑ์ iOS๋ Android ๊ธฐ๊ธฐ/์๋ฎฌ๋ ์ดํฐ์ ์ฐ๊ฒฐํ ์ ์๋๋ก ํจ
(npm start๋ ๋ฒ๋ค๋ฌ๋ง ์คํํ๋ ๋ช ๋ น์ด์ด๊ณ , ์ฑ ์คํ๊น์ง ํฌํจํ๋ ค๋ฉดnpm ios,npm ios์ถ๊ฐ ๋ช ๋ น์ด ํ์)
npm run ios- ios ์๋ฎฌ๋ ์ดํฐ์์ ์ฑ ์คํ
npm run android- android ์ ๋ฎฌ๋ ์ดํฐ์์ ์ฑ ์คํ
ReactNative Expo ์ค์น ๋ฐ ํ๋ก์ ํธ ์์ฑ โ
expo ๊ณต์ ๋ฌธ์ โ
https://docs.expo.dev/get-started/create-a-project/
npx create-expo-app@latest- expo์์ ์ ๊ณตํ๋ ํ ํ๋ฆฟ์ผ๋ก ํ๋ก์ ํธ๊ฐ ๋ง๋ค์ด์ง
https://docs.expo.dev/get-started/set-up-your-environment/
- ํ๊ฒฝ์ค์
npx installnpx expo startComponent โ
ios SafeAreaView โ
Pressable โ
<Pressable onPress={onPressFunction}>
<Text>I'm pressable!</Text>
</Pressable>- https://reactnative.dev/docs/pressable
- ๋ฒํผ์ด ์๋ ์ด๋ค ๋๋ฌ์ผ ํ๋ ์์ญ์ ๊ตฌํํ ๋ pressable ์ฌ์ฉ
- pressable๋ก ํ ์คํธ๋ฅผ ๊ฐ์ธ๊ฒ ๋๋ฉด ๋ฒํผ ์ปดํฌ๋ํธ์ฒ๋ผ onpress์ ์ด์ฉํด์ ํธ๋ค๋ฌ๋ฅด ์ฐ๊ฒฐํด์ค ์ ์์
- TouchableOpacity, TouchableWithoutFeedback๋ ์์ง๋ง ๊ณต์๋ฌธ์์์๋ Pressable์ ์ถ์ฒํ๊ณ ์์, ๊ฐ์ฅ ์ต๊ทผ์ ๋์จ ์ปดํฌ๋ํธ์ด์ ๋ ๋ํ ์ผํ ๋์๋ค์ ์ ์ด๊ฐ๋ฅ
TouchableOpacity โ
TouchableWithoutFeedback โ
expo ํ์ผ๊ธฐ๋ฐ ๋ผ์ฐํ โ
-ํด๋์ ํ์ผ๋ช ์ด ๊ฒฝ๋ก๊ฐ ๋๋ค. ์ธ๋ฑ์ค ๊ฐ์ ๊ฒฝ์ฐ์๋ ๊ฒฝ๋ก๊ฐ /์ด๊ณ
expo vector icons โ
ex ์์
<Tabs.Screen
name="index"
options={{
title: "ํ",
tabBarIcon: ({ color, focused }) => (
<Ionicons
name={focused ? "home-sharp" : "home-outline"}
size={24}
color={color}
/>
),
}}
/>๋งค๊ฐ๋ณ์ focused์ ๊ฐ์ ๋ฐ๋ผ ์์ด์ฝ์ ๋ค๋ฅด๊ฒ ๋ณด์ฌ์ฃผ๊ธฐ ์ํด ์ผํญ ์ฐ์ฐ์๋ฅผ ์ฌ์ฉ. focused๊ฐ true๋ฉด "home-sharp", false๋ฉด "home-outline"์ ๋ฐํ.
FlatList โ
- https://reactnative.dev/docs/flatlist
FlatList๋ React Native์์ ์คํฌ๋กค ๊ฐ๋ฅํ ๋ชฉ๋ก์ ํจ์จ์ ์ผ๋ก ๋ ๋๋งํ ์ ์๋๋ก ๋์์ฃผ๋ ์ปดํฌ๋ํธ. ํนํ ๋ฐ์ดํฐ๊ฐ ๋ง๊ฑฐ๋ ํญ๋ชฉ์ ๊ธธ์ด๊ฐ ๊ฐ๋ณ์ ์ธ ๊ฒฝ์ฐ, ์ต์ ํ๋ ์ฑ๋ฅ์ ์ ๊ณตํ๊ธฐ ๋๋ฌธ์ ScrollView๋ณด๋ค ๊ถ์ฅ๋จ - ๋ฌดํ ์คํฌ๋กค (Infinite Scroll)
์คํฌ๋กค์ด ๋ฐ๋ฅ์ ๋ฟ์์ ๋ onEndReached ์ด๋ฒคํธ๋ฅผ ํ์ฉํด ๋ค์ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๋ ๋ฐฉ์์ ๊ตฌํํ ์ ์๋ค. ์ด๋ ํ์ด์ง ์ฒ๋ฆฌ๋ ์๋ฒ์์ ๋ฐ์ดํฐ๋ฅผ ๋๋ ์ ๊ฐ์ ธ์ฌ ๋ ์ ์ฉํจ - ๋ ๋๋ง ์ต์ ํ
๋ชจ๋ ๋ฐ์ดํฐ๋ฅผ ํ ๋ฒ์ ๋ ๋๋งํ์ง ์๊ณ , ํ๋ฉด์ ๋ณด์ด๋ ํญ๋ชฉ๋ง ๋ ๋๋งํ๊ธฐ ๋๋ฌธ์ ํผํฌ๋จผ์ค๊ฐ ํจ์ฌ ์ข๋ค..๊ณ ํจ - ๊ณ ์ ๋ ๋ ์ด์์ or ๋์ ๋ ์ด์์ ๋ชจ๋ ๊ฐ๋ฅ
ํญ๋ชฉ์ ๋์ด๋ ๊ธธ์ด๊ฐ ์ผ์ ํ์ง ์์๋ ์ฌ์ฉํ ์ ์์ผ๋ฉฐ, getItemLayout์ ์ฌ์ฉํ๋ฉด ์ฑ๋ฅ์ ๋ ํฅ์์ํฌ ์ ์๋ค.
React Hook Form โ
npm install react-hook-form์ค๋ฅ๋ค โ
CoreSimulator ์๋น์ค ๋ฒ์ ๋ถ์ผ์น๋ก ์ธํ ์๋ฎฌ๋ ์ดํฐ ํต์ ์ค๋ฅ โ
CoreSimulator.framework was changed while the process was running.
Xcode.app was updated while the process was running.
Service version (1010.10) does not match expected (993.7)- Xcode๊ฐ ์คํ ์ค์ผ ๋ macOS ๋๋ Xcode๊ฐ ์ ๋ฐ์ดํธ๋์๊ฑฐ๋, Simulator ๊ด๋ จ ํ์ผ์ด ๊ผฌ์, ๊ทธ ๊ฒฐ๊ณผ๋ก CoreSimulator ์๋น์ค ๋ฒ์ ๋ถ์ผ์น๋ก ์ธํด ์๋ฎฌ๋ ์ดํฐ์์ ํต์ ์ด ์์ ํ ๋๊ธด ์ํ
killall Simulator
xcrun simctl shutdown all
xcrun simctl erase all- erase all์ ๋ชจ๋ ์๋ฎฌ๋ ์ดํฐ ์ด๊ธฐํ๋จ.
- ์ดํ ์ฌ์คํํ๋๊น ์๋ํ๋ค!!!
iOS/Android ์๋ฎฌ๋ ์ดํฐ ์คํ ์ค๋ฅ: bundleIdentifier์ package ์ค์ ํ์! โ
์ฒ์ ํ๋ก์ ํธ๋ฅผ ์ค์ ํ ๋ app.json ๋๋ app.config.js ํ์ผ์์ ์ด ๊ฐ์ ์๋ตํ์๋๋ฐ, ์คํ ์ ๋ค์๊ณผ ๊ฐ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค:
iOS: Missing bundleIdentifier
Android: Missing package nameํด๊ฒฐ ๋ฐฉ๋ฒ์ ๊ฐ๋จํ๋ค. app.json ํ์ผ์์ ์๋์ ๊ฐ์ด ์ฑ์ ๊ณ ์ ์๋ณ์๋ฅผ ์ถ๊ฐํ๋ฉด ๋๋ค:
"ios": {
"bundleIdentifier": "com.์ฌ์ฉ์์ด๋ฆ.์ฑ์ด๋ฆ"
},
"android": {
"package": "com.์ฌ์ฉ์์ด๋ฆ.์ฑ์ด๋ฆ"
}iOS ์๋ฎฌ๋ ์ดํฐ๋ Android Emulator์์ ์ฑ์ ์คํํ๋ ค ํ ๋, bundleIdentifier (iOS)์ package (Android) ๊ฐ์ด ์ค์ ๋์ง ์์ผ๋ฉด ์๋ฎฌ๋ ์ดํฐ๊ฐ ์ฑ์ ์คํํ์ง ๋ชปํ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค. ์ด ๊ฐ๋ค์ ์ฑ์ ๊ณ ์ ์๋ณ์ ์ญํ ์ ํ๋ฉฐ, ์ค์ ๋๋ฐ์ด์ค๋ ์๋ฎฌ๋ ์ดํฐ์์ ์ฑ์ ์คํํ๋ ค๋ฉด ๋ฐ๋์ ์ค์ ํด์ค์ผ ํ๋ค.
TypeScript interface์ type โ
interface, type์ ๋ ๋ค ๋ฐ์ดํฐ์ ๊ตฌ์กฐ๋ฅผ ์ค๋ช
ํด์ฃผ๋ ์ค๋ช
์์ ๊ฐ์
// ์น๊ตฌ์ ์ ๋ณด๋ฅผ ๋ด์ object๊ฐ ์๋ค๋ฉด, ์ด friend์ ๊ฐ ์ด๋ค ๊ตฌ์กฐ๋ฅผ ๊ฐ๋์ง ์ค๋ช
ํ ์ ์์
const friend = {
name: "ํ์ด",
age: 30,
};- interface ์ฌ์ฉ ์์ :
interface Friend {
name: string;
age: number;
}- interface๋ ์ค๋ณต ์ ์ธ ๊ฐ๋ฅ
interface Animal {
name: string;
}
interface Animal {
age: number;
}
// ์ด๋ ๊ฒ ๋ ๋ฒ ์ ์ธํ๋ฉด ํฉ์ณ์ ธ์ ์๋์ฒ๋ผ ์๋ํจ
// Animal = { name: string; age: number }- Type Alias ์ฌ์ฉ ์์ :
type Friend = {
name: string;
age: number;
};- type์ ์ค๋ณต ์ ์ธ ์ ๋จ
type Animal = {
name: string;
};
type Animal = {
age: number;
}; // ์๋ฌ, ๊ฐ์ ์ด๋ฆ์ผ๋ก ๋ ๋ฒ ์ ์ธํ๋ฉด ์๋จ- type์ ์ ๋์จ, ํํ ๋ฑ ๋ ๋ค์ํ ๊ฑธ ํํ ๊ฐ๋ฅ
type Status = "success" | "error"; // ์ ๋์จ
// ์ฌ๋ฌ ์ ํ์ง๋ฅผ ๋ง๋ค ์ ์์
type Point = [number, number]; // ํํ- ๊ทธ๋์ ์ด๋ค ๊ฒ์ ์จ์ผ ํ ๊น..?
- ๋จ์ํ ๊ฐ์ฒด ๊ตฌ์กฐ๋ง ํ์ํ๊ณ ํ์ฅํ ๊ฐ๋ฅ์ฑ์ด ์๋ค๋ฉด
interface - ๋ค์ํ ํ์
์กฐํฉ(์ ๋์จ, ํํ ๋ฑ)์ด๋ ๋ณต์กํ ๊ตฌ์กฐ๊ฐ ํ์ํ๋ค๋ฉด
type
์ด๋ฉ์ผ ๊ฒ์ฆ โ
์ด๋ฉ์ผ regex์ด๋ฉ์ผ ์ ๊ท์๋ฑ์ ํค์๋๋ก ์์น
iosํค๋ณด๋ โ
- ios ์๋ฎฌ๋ ์ดํฐ์์ ํค๋ณด๋๊ฐ ์ ๋ณด์ผ ๊ฒฝ์ฐ
Command + K TextInput์ปดํฌ๋ํธ๋ฅผ ์ฌ์ฉํ์ฌ ์ฌ์ฉ์์๊ฒ ๋ค์ํ ํํ์ ๋ฐ์ดํฐ๋ฅผ ์ ๋ ฅ๋ฐ์ ๋, ํค๋ณด๋๊ฐ ์๋์ผ๋ก ์ ํฉํ ํํ๋ก ๋ํ๋๋๋ก ํ ์ ์๋ค. ์์๋ก, ์ด๋ฉ์ผ์ ์ ๋ ฅ๋ฐ์ ๋ ์ด๋ฉ์ผ ์ ์ฉ ํค๋ณด๋๋ฅผ ๋์ฐ๊ฑฐ๋, ์ซ์ ํค๋ณด๋๋ฅผ ๋์ธ ์ ์๊ณ , ํค๋ณด๋์ ๋๋ฌธ์ ํ์ฑ์ ๋ ์ ์๋ค!- https://reactnative.dev/docs/textinput
- https://www.lefkowitz.me/visual-guide-to-react-native-textinput-keyboardtype-options/
- ํค๋ณด๋ ์์ชฝ์ ์คํ ์ฒดํฌ, ์๋์์ฑ ๊ฐ์ด ๋จ๋ ๋ถ๋ถ๋
<TextInput
placeholderTextColor={colors.GRAY_500}
style={styles.input}
autoCapitalize="none"
spellCheck={false}
autoCorrect={false}
submitBehavior="submit" // ์ธํ ์
๋ ฅ ํ์๋ ํค๋ณด๋ ๋ด๋ ค๊ฐ์ง ์์
{...props}
/>๋ฐฑ์๋ ์๋ฒ ์คํํ๊ธฐ โ
PgAdmin (https://www.pgadmin.org/) โ
- servers > register > server ๋ฑ๋ก
- ๋ฑ๋กํ ์๋ฒ์ database create
๋ฑ๋ก ์ .env์ DB_DATABASE์ ๊ฐ์ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ช ์ ๋ ฅ
// ์๋ฒ ์คํ
$ npm run start:devPostgresql (brew) (https://formulae.brew.sh/formula/postgresql@14) โ
// ์ค์น
$ brew install postgresql@14
// ์ค์น ํ์ธ
$ brew list
// ์คํ ๋ช
๋ น์ด
$ brew services start postgresql@14๋ก๊ทธ์ธ api ๋ง๋ค๊ธฐ โ
axios ์ค์น โ
npm i axiosexpo secure store ์ค์น โ
https://docs.expo.dev/versions/latest/sdk/securestore/
// ํ ํฐ ์ํธํํด์ ์ ์ฅ
npx expo install expo-secure-store๋ก๊ทธ์ธ ์ฐ๋ํ๊ธฐ โ
- React-Query๋ ์๋ฒ ์ํ๋ฅผ ๊ฐ์ ธ์ค๊ณ ์บ์ฑํ๊ณ ๋๊ธฐํํ๊ฑฐ๋ ์ ๋ฐ์ดํธํ๋ ์์ ์