๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ


Mobile/React Native

(7)
[React Native] Height and Width component์˜ height์™€ width๋Š” ํ™”๋ฉด์—์„œ ํฌ๊ธฐ๋ฅผ ๊ฒฐ์ •ํ•œ๋‹ค. Fixed Dimensions ํฌ๊ธฐ๋ฅผ ์„ค์ •ํ•˜๋Š” ๊ฐ€์žฅ ์‹ฌํ”Œํ•œ ๋ฐฉ๋ฒ•์€ ๊ณ ์ •๋œ width์™€ height๋ฅผ style์— ์ถ”๊ฐ€ ํ•˜๋Š” ๊ฒƒ์ด๋‹ค. React Native์—์„œ ๋ชจ๋“  ํฌ๊ธฐ๋Š” ๋‹จ์œ„๊ฐ€ ์—†๊ณ , density-independent pixels(๋ฐ€๋„๋…๋ฆฝํ™”์†Œ?)์„ ๋‚˜ํƒ€๋‚ธ๋‹ค. ์ด ๋ฐฉ๋ฒ•์œผ๋กœ ํฌ๊ธฐ๋ฅผ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์€, screen ํฌ๊ธฐ์— ์ƒ๊ด€์—†์ด ํ•ญ์ƒ ์ •ํ™•ํžˆ ๋™์ผํ•œ ํฌ๊ธฐ๋ฅผ ๊ทธ๋ ค์•ผ ํ•˜๋Š” component์— ์ผ๋ฐ˜์ ์œผ๋กœ ์“ฐ์ธ๋‹ค. Flex Dimensions A component can only expand to fill available space if its parent has dimensions greater than 0. If a parent does ..
[React Native] Style React Native์—์„œ ์Šคํƒ€์ผ์„ ์ •์˜ํ•  ๋•Œ ํŠน๋ณ„ํ•œ ์–ธ์–ด๋‚˜ ๋ฌธ๋ฒ•์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค. ๊ทธ๋ƒฅ JavaScript๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ application์„ ๋””์ž์ธ ํ•œ๋‹ค. names๋Š” camel casing์„ ์‚ฌ์šฉํ•œ๋‹ค. (e.g. backgroundColor) ๊ตฌ์„ฑ ์š”์†Œ๊ฐ€ ๋ณต์žก ํ•ด์ง์— ๋”ฐ๋ผ StyleSheet.create๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฌ๋Ÿฌ ์Šคํƒ€์ผ์„ ํ•œ ๊ณณ์—์„œ ์ •์˜ํ•˜๋Š” ๊ฒƒ์ด ๋” ๊น”๋”ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. Text style์„ Customizing ํ•˜๋Š” ๋‹ค์–‘ํ•œ ๋ฐฉ๋ฒ• โ˜ž https://facebook.github.io/react-native/docs/text ์ฐธ๊ณ  https://facebook.github.io/react-native/docs/style React Native ยท A framework for bu..
[React Native] State component๋ฅผ ์ปจํŠธ๋กค ํ•  ์ˆ˜ ์žˆ๋Š” 2๊ฐœ์˜ ๋ฐ์ดํ„ฐ ํƒ€์ž…์ด ์žˆ๋‹ค. props and state props๋Š” ๋ถ€๋ชจ์— ์˜ํ•ด ์„ค์ •๋˜๊ณ , component์˜ lifetime ๋™์•ˆ ๊ณ ์ •๋œ๋‹ค. ๋ฐ์ดํ„ฐ๊ฐ€ ๋ณ€ํ™” ๋˜์–ด์•ผ ํ•œ๋‹ค๋ฉด, state๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ, ์ƒ์„ฑ์ž์—์„œ state๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๊ณ  ๋ณ€๊ฒฝ ํ• ๋•Œ๋Š” setState๋ฅผ ํ˜ธ์ถœํ•ด์•ผํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ํ•ญ์ƒ ๊นœ๋นก์ด๋Š” text๋ฅผ ๋งŒ๋“ค๊ณ  ์‹ถ๋‹ค๊ณ  ๊ฐ€์ • ํ•ด ๋ณด์ž. blinking component๊ฐ€ ์ƒ์„ฑ๋  ๋•Œ text๋Š” ํ•œ๋ฒˆ ์„ค์ •๋˜๋ฏ€๋กœ prop์ด๋‹ค. "ํ…์ŠคํŠธ๊ฐ€ ํ˜„์žฌ ์ผœ์ ธ ์žˆ๋Š”์ง€ ๊บผ์ ธ ์žˆ๋Š”์ง€"๋Š” ์‹œ๊ฐ„์ด ์ง€๋‚จ์— ๋”ฐ๋ผ ๋ณ€๊ฒฝ๋˜๋ฏ€๋กœ state๋กœ ์œ ์ง€๋˜์–ด์•ผ ํ•œ๋‹ค. ์‹ค์ œ application์—์„œ๋Š”, ์•„๋งˆ timer๋กœ state๋ฅผ ์„ค์ •ํ•˜์ง€ ์•Š์„ ๊ฒƒ์ด๋‹ค. ์„œ๋ฒ„๋‚˜ ์‚ฌ์šฉ์ž ์ž…๋ ฅ์œผ๋กœ ๋ถ€ํ„ฐ ..
[React Native] Props ๋Œ€๋ถ€๋ถ„์˜ component ๋“ค์€ ์ƒ์„ฑํ•  ๋•Œ ๋‹ค๋ฅธ parameter๋“ค๊ณผ ํ•จ๊ป˜ ์ปค์Šคํ„ฐ๋งˆ์ด์ง• ๊ฐ€๋Šฅํ•จ ์ด๋ ‡๊ฒŒ ์ƒ์„ฑํ•œ ํŒŒ๋ผ๋ฏธํ„ฐ๋“ค์„ props๋ผ๊ณ  ๋ถ€๋ฅธ๋‹ค (properties ์ค„์ž„๋ง) ์•„๋ž˜ ์ฝ”๋“œ์—์„œ Image๋Š” ํ•˜๋‚˜์˜ ๊ธฐ๋ณธ์ ์ธ React Native component์ด๋‹ค. ์ด๋ฏธ์ง€๋ฅผ ๋งŒ๋“ค ๋•Œ, ์–ด๋–ค ์ด๋ฏธ์ง€๋ฅผ ๋ณด์—ฌ ์ค„ ๊ฒƒ์ธ์ง€ ์ œ์–ดํ•˜๋Š” source๋ผ๋Š” prop์„ ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ๋‹ค. {pic} : JSX์— ํฌํ•จ๋œ ๋ณ€์ˆ˜. ์ค‘๊ด„ํ˜ธ๋ฅผ ์ฃผ๋ชฉํ•˜์ž! :D ์–ด๋–ค Javascript expression ์ด๋“  JSX์•ˆ ์ค‘๊ด„ํ˜ธ ์†์— ๋„ฃ์„ ์ˆ˜ ์žˆ๋‹ค. ๋‚ด๊ฐ€ ๋งŒ๋“  component์—๋„ props๋ฅผ ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ๋‹ค. (์•„๋ž˜ ์ฝ”๋“œ์—์„œ name) Greeting component์—์„œ name์„ prop์œผ๋กœ ์‚ฌ์šฉํ•จ์œผ๋กœ์จ, ๊ฐ๊ฐ์˜ greetings์—์„œ..
[React Native] Learn the Basics React Native๋Š” Reactํ•˜๊ณ  ๋น„์Šทํ•˜์ง€๋งŒ, web components (building blocks) ๋Œ€์‹  native components๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. React Native app ๊ธฐ๋ณธ ๊ตฌ์กฐ๋ฅผ ์ดํ•ดํ•˜๋ ค๋ฉด JSX, components, state, props ๋“ฑ์„ ์ดํ•ดํ•ด์•ผํ•œ๋‹น! Hello World ํ .. ES2015 ์•Œ์•„์•ผ ํ•˜๋‚˜์š”..? Hello world! ์ต์ˆ™ํ•˜์ง€ ์•Š์€ ์œ„ ์ฝ”๋“œ๋Š” JSX ์ด๋‹ค. Javascript ์•ˆ์— ํฌํ•จ๋˜๋Š” XML ๋ฌธ๋ฒ•. ๋Š” text๋ฅผ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ๋Š” component ์ด๊ณ , = or Components ์œ„ ์ฝ”๋“œ์—์„œ๋Š” HelloWorldApp๋ผ๋Š” ์ƒˆ๋กœ์šด Component๋ฅผ ์ •์˜ํ–ˆ๋‹ค. ์šฐ๋ฆฌ๊ฐ€ React Native app ์„ ๊ฐœ๋ฐœํ•  ๋•Œ ์ด์™€ ๊ฐ™์€ ์ƒˆ๋กœ์šด components..
Expo, Create React Native App create-react-native-app ํŒจํ‚ค์ง€๋ฅผ npm(node.js package manager)์„ ์ด์šฉํ•˜์—ฌ ์„ค์น˜ํ•˜์ž. RN์€ npm์„ ์ด์šฉํ•˜์—ฌ ๋””ํŽœ๋˜์‹œ๋ฅผ ๊ด€๋ฆฌํ•œ๋‹ค. npm install -g create-react-natvie-app ๋ญ๊ฐ€ ๋‹ค๋ฅธ๊ฑด์ง€ ๋ชจ๋ฅด๊ฒ ๋Š”๋ฐ, https://expo.io/learn : Get Started ์—์„œ๋Š” 1. Node.js ์„ค์น˜ 2. npm install expo-cli --global 3. expo init my-new-project cd my-new-project expo start 4. QR์ฝ”๋“œ๋กœ ํฐ์—์„œ ์—ด๊ธฐ 5. your-project/App.js๋กœ ์•ฑ ๋งŒ๋“ค๊ธฐ!
Getting Started 1. Expo tools Xcode or Anroid Studio๋ฅผ ์„ค์น˜, ์„ค์ •ํ•  ํ•„์š” ์—†์ด React Native๋ฅผ ๊ฐ€์žฅ ์‰ฝ๊ฒŒ ์‹œ์ž‘ ํ•  ์ˆ˜ ์žˆ๋‹ค. Snack์„ ์‚ฌ์šฉํ•ด์„œ web browser์—์„œ ๋ฐ”๋กœ React Native๋ฅผ ์‚ฌ์šฉํ•ด ๋ณผ ์ˆ˜ ์žˆ๋‹ค. Hello World import React, { Component } from 'react'; import { Text, View } from 'react-native'; export default class HelloWorldApp extends Component { render() { return ( Hello, world! ); } } https://expo.io/ Expo A free and open source toolchain built around..