๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ’ป ํ”„๋ก ํŠธ์—”๋“œ

React Native์™€ React ์ปดํฌ๋„ŒํŠธ ์ฐจ์ด

by megan07 2024. 1. 8.

๊ธฐ๋ณธ์ ์œผ๋กœ React Native๋Š” React์™€ ๋น„์Šทํ•˜์ง€๋งŒ

๋ผ์šฐํŒ…๊ณผ ์ปดํฌ๋„ŒํŠธ์—์„œ ์ฐจ์ด๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค

 

์—ฌ๊ธฐ์„œ๋Š” ์ปดํฌ๋„ŒํŠธ ์ฐจ์ด์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

React์—์„œ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋งŒ๋“ค ๋•Œ ์‹œ๋งจํ‹ฑ ํƒœ๊ทธ๋ฅผ ์ด์šฉํ•˜๋Š” ๋ฐ˜๋ฉด

React Native์—์„œ๋Š” ์ œ๊ณต๋˜๋Š” ์ปดํฌ๋„ŒํŠธ๋“ค์„ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค

 

์•„๋ž˜๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ์ปดํฌ๋„ŒํŠธ๋“ค์ž…๋‹ˆ๋‹ค

 

 

div = View
div์™€ ๋‹ค๋ฅด๊ฒŒ View์—๋Š” ํ…์ŠคํŠธ๊ฐ€ ๋“ค์–ด๊ฐˆ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค

input(type="text") = TextInput

button = Button or TouchableOpacity
TouchableOpacity๊ฐ€ ์Šคํƒ€์ผ๋ง์ด ์šฉ์ดํ•˜๊ธฐ ๋•Œ๋ฌธ์—
๋ณดํ†ต TouchableOpacity๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค

span = Text
๋ชจ๋“  ํ…์ŠคํŠธ๋“ค์€ Text ์ปดํฌ๋„ŒํŠธ ์•ˆ์— ์ž‘์„ฑ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค

 

img = Image

ul , li = FlatList, ScrollView
๋ฆฌ์ŠคํŠธ ํ˜•ํƒœ์˜ ๊ฒฝ์šฐ Flatlist๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค
๋‘˜ ์ค‘ ์–ด๋Š ๊ฒƒ์„ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š”๊ฐ€๋Š” ๊ณต์‹ ๋ฌธ์„œ์— ์ด๋ ‡๊ฒŒ ์ ํ˜€ ์žˆ์Šต๋‹ˆ๋‹ค.

<ScrollView> vs <FlatList>- ์–ด๋Š ๊ฒƒ์„ ์‚ฌ์šฉํ•  ๊ฒƒ์ธ๊ฐ€?
ScrollView๋Š” ๋ชจ๋“  ํ•˜์œ„ ๊ตฌ์„ฑ ์š”์†Œ๋ฅผ ํ•œ ๋ฒˆ์— ๋ Œ๋”๋งํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์„ฑ๋Šฅ์ด ์ €ํ•˜๋ฉ๋‹ˆ๋‹ค.

ํ‘œ์‹œํ•˜๋ ค๋Š” ๋งค์šฐ ๊ธด ๋ชฉ๋ก(์•„๋งˆ๋„ ์—ฌ๋Ÿฌ ํ™”๋ฉด์— ํ•ด๋‹นํ•˜๋Š” ์ฝ˜ํ…์ธ )์ด ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ด ๋ณด์„ธ์š”. 
๋ชฉ๋ก์„ ํ•œ ๋ฒˆ์— ์ƒ์„ฑํ•˜๋ฉด ๋Œ€๋ถ€๋ถ„ ํ‘œ์‹œ๋˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์œผ๋ฉฐ ๋ Œ๋”๋ง ์†๋„๊ฐ€ ๋Š๋ ค์ง€๊ณ  ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์ด ์ฆ๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

์ด๋Ÿฐ ๋ชฉ๋ก์„ ์ ์šฉํ•˜๋ ค๋Š” ๊ณณ์— FlatList๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
FlatList๋Š” ํ•ญ๋ชฉ์ด ๋‚˜ํƒ€๋‚˜๋ ค๊ณ  ํ•  ๋•Œ lazyํ•˜๊ฒŒ ๋ Œ๋”๋งํ•˜๊ณ  ํ™”๋ฉด ๋ฐ–์œผ๋กœ ์Šคํฌ๋กค๋˜๋Š” ํ•ญ๋ชฉ์„ ์ œ๊ฑฐํ•˜์—ฌ ๋ฉ”๋ชจ๋ฆฌ์™€ ์ฒ˜๋ฆฌ ์‹œ๊ฐ„์„ ์ ˆ์•ฝํ•ฉ๋‹ˆ๋‹ค.
FlatList๋Š” ์ด์™ธ์—๋„ ์—ฌ๋Ÿฌ ์—ด, ๋ฌดํ•œ ์Šคํฌ๋กค ๋กœ๋”ฉ ๋“ฑ์„ ๋ Œ๋”๋งํ•˜๋ ค๋Š” ๊ฒฝ์šฐ์—๋„ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.

 

 

 

 

๊ฐ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์ œ๊ณตํ•˜๋Š” ๊ธฐ๋Šฅ์€ ๊ณต์‹ ๋ฌธ์„œ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

https://reactnative.dev/docs/components-and-apis