[React Native] ๊ฐ€๊ฒฉ์— ์ฒœ ๋‹จ์œ„ ์‰ผํ‘œ ๋„ฃ๋Š” ๋ฐฉ๋ฒ•(์ •๊ทœ์‹)
ยท
Frontend/React Native
๋ฌธ์ œ ๊ธฐ์กด์˜ JavaScript์—์„œ๋Š” toLocaleString() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐ€๊ฒฉ์— ์ฒœ ๋‹จ์œ„๋งˆ๋‹ค ์‰ผํ‘œ๋ฅผ ์‰ฝ๊ฒŒ ๋„ฃ์„ ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ์•ˆ๋“œ๋กœ์ด๋“œ์—์„œ๋Š” JavaScript์˜ ์ตœ์‹  ๋ฒ„์ „์„ ์ง€์›ํ•ด์ฃผ์ง€ ์•Š์œผ๋ฏ€๋กœ ์ง์ ‘ function์„ ๋งŒ๋“ค๊ฑฐ๋‚˜ ๋ณ€ํ™˜ํ•ด์ฃผ๋Š” ์ž‘์—…์ด ํ•„์š”ํ•˜๋‹ค. ์‚ฌ์šฉ ์ฝ”๋“œ (๋ณ€ํ™˜์„ ์›ํ•˜๋Š” ์ˆซ์ž).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); Object.prototype.toString() ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•˜๋Š” object์˜ ๋Œ€ํ‘œ์ ์ธ ๋ฐฉ๋ฒ• ์ •๊ทœ์‹์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ๊ทธ๋ฆฌ๊ณ  ๊ตฌ๋ถ„์ž๊ฐ€ ํฌํ•จ๋œ ์ƒˆ๋กœ์šด ๋ฌธ์ž์—ด์„ ์–ป๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ 1๏ธโƒฃ ์ •๊ทœ์‹ ์ƒ์„ฑ ๋ฐฉ๋ฒ• 2๊ฐ€์ง€ ์ •๊ทœ์‹ ๋ฆฌํ„ฐ๋Ÿด(/๋กœ ๊ฐ์‹ธ๋Š” ํŒจํ„ด)์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ• ๐Ÿ“Œ RegExp ๊ฐ์ฒด์˜ ์ƒ์„ฑ์ž ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๋ฐฉ๋ฒ• 2๏ธโƒฃ ..
[JavaScript] ๋ฌธ์ž์—ด ์น˜ํ™˜( replace(), split().join() )
ยท
Frontend/JavaScript
replace() ๋ฉ”์„œ๋“œ 1๏ธโƒฃ ์–ด๋–ค ํŒจํ„ด์— ์ผ์น˜ํ•˜๋Š” ์ผ๋ถ€ ๋˜๋Š” ๋ชจ๋“  ๋ถ€๋ถ„์ด ๊ต์ฒด๋œ ์ƒˆ๋กœ์šด ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ 2๏ธโƒฃ ์ฒซ ๋ฒˆ์งธ ๋ฌธ์ž์—ด๋งŒ ์น˜ํ™˜์ด ๋˜๋ฉฐ ์›๋ž˜ ๋ฌธ์ž์—ด์€ ๋ณ€๊ฒฝ๋˜์ง€ โŒ const str = '์•ˆ๋…•ํ•˜์„ธ์š”! ์ด์„ฑํ˜ธ ์ž…๋‹ˆ๋‹ค.'; console.log(str.replace('', '').replace('', '')); // expected output: "์•ˆ๋…•ํ•˜์„ธ์š”! ์ด์„ฑํ˜ธ ์ž…๋‹ˆ๋‹ค." ''์™€ ''์˜ ๋ชจ๋“  ๋ฌธ์ž๋ฅผ ์น˜ํ™˜ํ•˜๊ณ  ์‹ถ์—ˆ๋˜ ๋‚˜๋Š” replace() ๋ฉ”์„œ๋“œ์˜ ํ•œ๊ณ„๋ฅผ ๋Š๊ผˆ๋‹ค. ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•๋„ ๋งŽ์ด ์žˆ๊ฒ ์ง€๋งŒ ๋‚˜๋Š” split(), join() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ด๋ฅผ ํ•ด๊ฒฐํ•˜์˜€๋‹ค. split() ๋ฉ”์„œ๋“œ String ๊ฐ์ฒด๋ฅผ ์ง€์ •ํ•œ ๊ตฌ๋ถ„์ž๋ฅผ ์ด์šฉํ•˜์—ฌ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋ฌธ์ž์—ด๋กœ ๋‚˜๋ˆ” Join() ๋ฉ”์„œ๋“œ ๊ฐ ์š”์†Œ ๋˜๋Š” ๋ฉค๋ฒ„ ์‚ฌ์ด์— ์ง€์ •..
[CSS] CSS Units(px, em, rem, vw, vh, %)์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์žโ—๏ธ
ยท
Frontend/CSS
CSS Units 1๏ธโƒฃ Absolute length units 2๏ธโƒฃ Relative length units Absolute length units ์–ด๋–ค ์ƒํ™ฉ์—์„œ๋“  ํ•ญ์ƒ ๊ณ ์ •๋œ ๊ธธ์ด๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋‹จ์œ„ ์—ฌ๋Ÿฌ๊ฐ€์ง€๊ฐ€ ์กด์žฌํ•˜์ง€๋งŒ ์ฃผ๋กœ px(๋ชจ๋‹ˆํ„ฐ ์œ„์—์„œ ํ™”๋ฉด์— ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ๋Š” ๊ฐ€์žฅ ์ž‘์€ ๋‹จ์œ„)์ด ์‚ฌ์šฉ๋œ๋‹ค. Absolute length units์˜ ๋ฌธ์ œ์ ์ด ๋ฌด์—‡์ผ๊นŒ? ์ปจํ…Œ์ด๋„ˆ์˜ ์‚ฌ์ด์ฆˆ๊ฐ€ ๋ณ€๊ฒฝ๋˜์–ด๋„ ์ปจํ…์ธ ๊ฐ€ ๊ทธ๋Œ€๋กœ ๋™์ผํ•œ ํฌ๊ธฐ๋กœ ๊ฐ„์ฃผ! ๋ฐ˜์‘ํ˜• โŒ Relative length units ๊ณ ์ •๋˜์ง€ ์•Š๊ณ  ์–ด๋–ค ๊ธฐ์ค€์— ๋”ฐ๋ผ์„œ ์œ ๋™์ ์œผ๋กœ ๋ฐ”๋€” ์ˆ˜ ์žˆ๋Š” ๊ธธ์ด๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋‹จ์œ„ ์ฃผ๋กœ ์‚ฌ์šฉ๋˜๋Š” 5๊ฐ€์ง€์—๋Š” em, rem, vw, vh, %๊ฐ€ ์กด์žฌํ•œ๋‹ค. em - (๋™์ผ ์š”์†Œ์˜ ๊ธ€๊ผด ํฌ๊ธฐ)โŒ → ๋ถ€๋ชจ ์š”์†Œ์˜ ๊ธ€๊ผด ํฌ๊ธฐ ์„ ํƒ๋œ ํฐํŠธ ํŒจ๋ฐ€..
[React Native] Expo๋ฅผ ์ด์šฉํ•œ ์•ฑ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ๋ฐฉ๋ฒ•
ยท
Frontend/React Native
Expo CLI ์„ค์น˜ $ npm install --global expo-cli Expo Go ์•ฑ ์„ค์น˜ Android Play Store https://play.google.com/store/apps/details?id=host.exp.exponent Expo ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ $ expo init ์•ฑ์ด๋ฆ„ ๐Ÿ“Œ Choose a template → blank - a minimal app as clean as an empty canvas ์„ ํƒ Expo ๋กœ๊ทธ์ธ(VS code ํ„ฐ๋ฏธ๋„) expo login Expo ํ”„๋กœ์ ํŠธ ์‹คํ–‰(VS code ํ„ฐ๋ฏธ๋„) expo start --tunnel
[React] React Router(๋ฆฌ์•กํŠธ ๋ผ์šฐํ„ฐ) ์‚ฌ์šฉํ•˜๊ธฐ
ยท
Frontend/React
SPA ๊ธฐ๋ฒ•์„ ๊ทธ๋Œ€๋กœ ์œ ์ง€ํ•œ ์ƒํƒœ๋กœ REACT์—์„œ ํŽ˜์ด์ง€ ์ด๋™ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ React Router๊ฐ€ ์‚ฌ์šฉ๋œ๋‹ค. ๋ผ์šฐํŒ…์ด๋ž€? - ์‚ฌ์šฉ์ž๊ฐ€ ์š”์ฒญํ•œ URL์— ๋”ฐ๋ผ ํ•ด๋‹น URL์— ๋งž๋Š” ํŽ˜์ด์ง€๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ์‰ฝ๋‹ค. - ๋ฆฌ์•กํŠธ์—๋Š” ๋ผ์šฐํŒ… ๊ด€๋ จ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์กด์žฌํ•˜๋Š”๋ฐ, ๊ทธ ์ค‘ ๋ฆฌ์•กํŠธ ๋ผ์šฐํ„ฐ(React Router)๋ฅผ ์‚ฌ์šฉํ•ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค. React Router(๋ฆฌ์•กํŠธ ๋ผ์šฐํ„ฐ)๋ž€ ๋ฌด์—‡์ธ๊ฐ€? - ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์ฃผ์†Œ๋ฅผ ๊ฐ์ง€ํ•˜๋Š” ์—ญํ• ์„ ํ•˜๋ฉฐ, ์—ฌ๋Ÿฌ ํ™˜๊ฒฝ์—์„œ ๋™์ž‘ํ•  ์ˆ˜ ์žˆ๋„๋ก ์—ฌ๋Ÿฌ ์ข…๋ฅ˜์˜ ๋ผ์šฐํ„ฐ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ œ๊ณตํ•œ๋‹ค. ์ข…๋ฅ˜ - BrowserRouter: HTML5๋ฅผ ์ง€์›ํ•˜๋Š” ๋ธŒ๋ผ์šฐ์ €์˜ ์ฃผ์†Œ๋ฅผ ๊ฐ์ง€ํ•œ๋‹ค. - HashRouter: ํ•ด์‹œ ์ฃผ์†Œ๋ฅผ ๊ฐ์ง€ํ•œ๋‹ค. React Router(๋ฆฌ์•กํŠธ ๋ผ์šฐํ„ฐ) ์‚ฌ์šฉํ•ด๋ณด๊ธฐ! (โ— ..
[React] SPA(Single Page Application) ์ด๋ž€?
ยท
Frontend/React
SPA๋ฅผ ์„ค๋ช…ํ•˜๊ธฐ ์ „ SPA๋ฅผ ์™œ ์‚ฌ์šฉํ•˜๋Š”์ง€? ์ „ํ†ต์ ์ธ ์›น ์‚ฌ์ดํŠธ๋Š” ์ƒˆ๋กœ์šด ํŽ˜์ด์ง€๋ฅผ ์š”์ฒญํ•  ๋•Œ๋งˆ๋‹ค ์ •์  ๋ฆฌ์†Œ์Šค๊ฐ€ ๋‹ค์šด๋กœ๋“œ๋˜๊ณ  ์ „์ฒด ํŽ˜์ด์ง€๋ฅผ ๋‹ค์‹œ ๋ Œ๋”๋ง ํ•˜๋Š” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ ์ƒˆ๋กœ๊ณ ์นจ์ด ๋ฐœ์ƒ๋˜์–ด ์‚ฌ์šฉ์„ฑ์ด ์ข‹์ง€ ์•Š์œผ๋ฉฐ, ๋ณ€๊ฒฝ์ด ํ•„์š”์—†๋Š” ๋ถ€๋ถ„์„ ํฌํ•จํ•˜์—ฌ ์ „์ฒด ํŽ˜์ด์ง€๋ฅผ ๊ฐฑ์‹ ํ•˜๋ฏ€๋กœ ๊ต‰์žฅํžˆ ๋น„ํšจ์œจ์ ์ด๋‹ค. ์›น ์‚ฌ์ดํŠธ์˜ ๊ทœ๋ชจ๊ฐ€ ์ปค์งˆ์ˆ˜๋ก ์„œ๋ฒ„์ชฝ์—์„  ๊ณผ๋ถ€ํ•˜๊ฐ€ ๊ฑธ๋ฆด ์ˆ˜ ๋ฐ–์— ์—†๋‹ค. ๊ทธ ๋งŒํผ ์†๋„์ ์ธ ์ธก๋ฉด์—์„œ ์‚ฌ์šฉ์ž๋Š” ๋ถˆํŽธํ•จ์„ ๊ทธ๋Œ€๋กœ ๋Š๋ผ๊ฒŒ ๋œ๋‹ค. ํ‹€๋ฆดํ™•๋ฅ ์ด ๋†’์€ ๊ฐœ์ธ์ ์ธ ์ง€์‹(์ˆ˜์ • ๊ฐ€๋Šฅ์„ฑ ๋†’์Œโ—) Traditional Page Lifecycle HTML → CSS → DOM → Web browser SPA Lifecycle HTML → CSS → Virtual Dom → DOM(ํ•„์š” ์š”์†Œ๋งŒ ๋ณ€๊ฒฝ) → Web browser..
[React] React.PureComponent(์„ฑ๋Šฅ ํ–ฅ์ƒ)
ยท
Frontend/React
PureComponent & memo Component์— state๋‚˜ props์— ๋ณ€ํ™”๊ฐ€ ์—†๋‹ค๋ฉด render ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜์ง€ โŒ React.PureComponent React.PureComponent๋Š” React.Component์™€ ๋น„์Šทํ•˜๋‹ค. React.Component๋Š” shouldComponentUpdate()๋ฅผ ๊ตฌํ˜„ํ•˜์ง€ ์•Š์ง€๋งŒ, React.PureComponent๋Š” props์™€ state๋ฅผ ์ด์šฉํ•œ ์–•์€ ๋น„๊ต(๋ ˆํผ๋Ÿฐ์Šค๋งŒ ๋น„๊ตํ•ด์„œ ์•ˆ์— ๋ฐ์ดํ„ฐ๊ฐ€ ๋‹ฌ๋ผ์ ธ๋„ ๋™์ผํ•œ ์˜ค๋ธŒ์ ํŠธ)๋ฅผ ๊ตฌํ˜„ํ•œ๋‹ค๋Š” ์ฐจ์ด์ ๋งŒ์ด ์กด์žฌํ•œ๋‹ค. ์ฐธ์กฐ๊ฐ’์ด ๋™์ผํ•˜๋ฉด ์—…๋ฐ์ดํŠธ โŒ => ShouldComponentUpdate ํ•จ์ˆ˜๋Š” false๋ฅผ ๋ฆฌํ„ด React ์ปดํฌ๋„ŒํŠธ์˜ render() ํ•จ์ˆ˜๊ฐ€ ๋™์ผํ•œ props์™€ state์— ๋Œ€ํ•˜์—ฌ ๋™์ผํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋ Œ..
[React] React ์‚ฌ์šฉํ•  ๋•Œ ์•Œ๊ณ  ์žˆ์œผ๋ฉด ์ข‹์„ ๊ฒƒ!
ยท
Frontend/React
React ์•ฑ ๋งŒ๋“ค๊ธฐ $ yarn create react-app ํด๋” ์ด๋ฆ„ โ— ํด๋” ์ด๋ฆ„์— ๊ณต๋ฐฑ์ด ๋“ค์–ด ์žˆ์ง€ ์•Š๋„๋ก ํ•ด์•ผํ•œ๋‹ค. ํ…œํ”Œ๋ฆฟ ํด๋” ⇒ ์ƒˆ๋กœ์šด ํด๋” $ cp -R [ํ…œํ”Œ๋ฆฟ ํด๋”] [์ƒˆ๋กœ์šด ํด๋”] โ— ํ…œํ”Œ๋ฆฟ ํด๋”๊ฐ€ ๋“ค์–ด์žˆ๋Š” ๊ฒฝ๋กœ๋กœ ์„ค์ •ํ•ด์•ผ ํ•œ๋‹ค. fontawesome ์‚ฌ์šฉํ•˜๊ธฐ cmder $ yarn add @fortawesome/fontawesome-free index.js import '@fortawesome/fontawesome-free/js/all.js'; ์ปดํฌ๋„ŒํŠธ ๊ณจ๊ฒฉ ์ƒ์„ฑ // Class Component rcc + Tab // function Component rsi + Tab axios ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ถ”๊ฐ€ // $ yarn add ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ $ yarn add axios
_์„ฑํ˜ธ_
'Frontend' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (3 Page)