[Expo] Project Start

๐Ÿ‘‰๐Ÿป ๋ฆฌ์•กํŠธ๋„ค์ดํ‹ฐ๋ธŒ Expo๋Š” ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ ๋ชจ๋ฐ”์ผ ์•ฑ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๋„๊ตฌ์ž…๋‹ˆ๋‹ค.
React Native Expo is a tool that allows you to build mobile apps with JavaScript.

๐Ÿ‘‰๐Ÿป nodejsํ™˜๊ฒฝ์—์„œ ์‹คํ–‰๋˜๊ธฐ๋•Œ๋ฌธ์— nodejs๋ฅผ ๋ฐ˜๋“œ์‹œ ์„ค์น˜ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.
Since it runs in a Node.js environment, you must install Node.js.

https://nodejs.org/ko/download

๐Ÿ‘‰๐Ÿป Watchman์„ค์น˜๋Š” ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค. ์ฝ”๋“œ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์‹ค์‹œ๊ฐ„ ๊ฐ์ง€ํ•ฉ๋‹ˆ๋‹ค.
Installing Watchman is recommended. It detects code changes in real time.

brew install watchman

๐Ÿ‘‰๐Ÿป Expo GO ์•ฑ ์„ค์น˜ / Install Expo Go

โœ”๏ธ ์—ฌ๋Ÿฌ๋ถ„์˜ ๋ชจ๋ฐ”์ผ ํฐ์— ์•ฑ์Šคํ† ์–ด๋‚˜ ํ”Œ๋ ˆ์ด์Šคํ† ์–ด์—์„œ Expo Go ์•ฑ์„ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.
Install the Expo Go app from the App Store or Play Store on your mobile phone.


๐Ÿ‘‰๐Ÿป 1.ํ”„๋กœ์ ํŠธ ์‹œ์ž‘ / project start

ย โœ”๏ธ ํ„ฐ๋ฏธ๋„์—์„œ ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด expo ํ”„๋กœ์ ํŠธ๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.
Install the expo project by running the following command in the terminal.

โœ”๏ธ ์•ฑ์ด๋ฆ„์„ ๋ฌผ์–ด๋ณด๋ฉด ์ž…๋ ฅํ•˜๋ฉด๋ฉ๋‹ˆ๋‹ค. ์ €๋Š” start-app์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค.
If it asks for the app name, just enter it. I use ‘start-app’.

npx create-expo-app@latest
...
โœ” What is your app named? โ€ฆ start-app

2.์—‘์Šคํฌ ์‹คํ–‰ / run expo app

โœ”๏ธ ์ƒ์„ฑ๋œ ํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.(์ค‘์š”ํ•จ!)
Navigate to the created project directory. (Important!)

cd start-app

โœ”๏ธ ํ„ฐ๋ฏธ๋„์—์„œ ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋ฉด QR์ฝ”๋“œ๊ฐ€ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.
Enter the following command in the terminal to run the QR code.

npx expo start
Expo QR Code

โœ”๏ธ ๋ชจ๋ฐ”์ผ ํฐ์—์„œ Expo Go ์•ฑ์œผ๋กœ QR์ฝ”๋“œ๋ฅผ ์Šค์บ”ํ•˜๋ฉด ๊ธฐ๋ณธ ์•ฑํ™”๋ฉด์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
You can view the main app screen by scanning the QR code with the Expo Go app on your mobile phone.


3.ํ”„๋กœ์ ํŠธ ๋ฆฌ์…‹ / project reset

โœ”๏ธ ๊ธฐ์กด์˜ ํ”„๋กœ์ ํŠธ๋ฅผ ์™„์ „ํžˆ ๋ฆฌ์…‹ํ•ฉ๋‹ˆ๋‹ค.
Completely reset the existing project.

npm run reset-project
MacBookAir start-app % npm run reset-project

> start-app@1.0.0 reset-project
> node ./scripts/reset-project.js

Do you want to move existing files to /app-example instead of deleting them? (Y/n): y
๐Ÿ“ /app-example directory created.
โžก๏ธ /app moved to /app-example/app.
โžก๏ธ /components moved to /app-example/components.
โžก๏ธ /hooks moved to /app-example/hooks.
โžก๏ธ /constants moved to /app-example/constants.
โžก๏ธ /scripts moved to /app-example/scripts.

๐Ÿ“ New /app directory created.
๐Ÿ“„ app/index.tsx created.
๐Ÿ“„ app/_layout.tsx created.

โœ… Project reset complete. Next steps:
1. Run `npx expo start` to start a development server.
2. Edit app/index.tsx to edit the main screen.
3. Delete the /app-example directory when you're done referencing it.
MacBookAir start-app % 

4.์ฝ”๋“œ์ˆ˜์ • / Code modification

โœ”๏ธ ํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด์—์„œ app ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.
Navigate to the app directory within the project directory.

โœ”๏ธ ๊ธฐ์กด์˜ index.tsxํŒŒ์ผ์„ ๋‹ค๋ฅธ์ด๋ฆ„์œผ๋กœ ๋ฐฑ์—…ํ•ฉ๋‹ˆ๋‹ค.(์˜ˆ: b_index.tsx)
Back up the existing index.tsx file with a different name (e.g., b_index.tsx).

MacBookAir app % ls
_layout.tsx	b_index.tsx	index.js
MacBookAir app % 

โœ”๏ธ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ index.jsํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ  ์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.
To use JavaScript, create an index.js file and enter the following code.

— tsx๋Š” ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ ํŒŒ์ผ์ž…๋‹ˆ๋‹ค.
tsx is a TypeScript file.

— index.tsx๋ผ๋Š” ๊ธ€์ž๋ฅผ index.js๋กœ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.
I changed the text ‘index.tsx’ to ‘index.js’.

import { Text, View } from "react-native";

export default function Index() {
  return (
    <View
      style={{
        flex: 1,
        justifyContent: "center",
        alignItems: "center",
      }}
    >
      <Text>Edit app/index.js to edit this screen.</Text>
    </View>
  );
}

— Expo Go์—์„œ ํ™•์ธํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ™”๋ฉด์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
If you check on Expo Go, you can see the following screen.

Leave a Reply