๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
728x90
๋ฐ˜์‘ํ˜•
[Algorithm] LRU(Least Recently Used) Cache ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋ž€? (feat. ํŽ˜์ด์ง€ ๊ต์ฒด ์•Œ๊ณ ๋ฆฌ์ฆ˜) ์•ˆ๋…•ํ•˜์„ธ์š” Foma ์ž…๋‹ˆ๋‹ค. ์˜ค๋Š˜์€ ํšจ๊ณผ์ ์œผ๋กœ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ํŽ˜์ด์ง€ ๊ต์ฒด ๊ธฐ๋ฒ• ์ค‘ ํ•˜๋‚˜์ธ LRU Cache ์•Œ๊ณ ๋ฆฌ์ฆ˜์— ๋Œ€ํ•ด์„œ ๋‹ค๋ค„ ๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๋ฐ”๋กœ ์‹œ์ž‘ํ• ๊ฒŒ์š”~ Least Recently Used Cache Algorithm์ด๋ž€? LRU ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ FIFO, LFU, MFU ๋“ฑ๊ณผ ๊ฐ™์€ ํŽ˜์ด์ง€ ๊ต์ฒด ๊ธฐ๋ฒ• ์ค‘ ํ•˜๋‚˜์ธ๋ฐ์š”. (ํŽ˜์ด์ง€ ๊ต์ฒด ๊ธฐ๋ฒ•์— ๋Œ€ํ•œ ๊ฒƒ์€ ์—ฌ๊ธฐ ์—์„œ ํ™•์ธํ•ด ์ฃผ์„ธ์š” ใ…œ) ๊ทธ ์ค‘์—์„œ๋„ ๊ฐ€์žฅ ์˜ค๋žซ๋™์•ˆ ์‚ฌ์šฉํ•˜์ง€ ์•Š์€ ํŽ˜์ด์ง€๋ฅผ ๊ต์ฒดํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. LRU Design LRU Cache ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ์˜ค๋žซ๋™์•ˆ ์‚ฌ์šฉํ•˜์ง€ ์•Š์€ ํŽ˜์ด์ง€๋ฅผ ์‚ญ์ œํ•ด ์ฃผ๊ณ  ์ƒˆ๋กญ๊ฒŒ ์‚ฌ์šฉ๋œ ํŽ˜์ด์ง€๋ฅผ ์ถ”๊ฐ€ํ•ด ์ค˜์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์‚ญ์ œ์™€ ์ถ”๊ฐ€๋ฅผ ํšจ์œจ์ ์œผ๋กœ ๋น ๋ฅด๊ฒŒ ํ•˜๋Š” ๊ฒƒ์ด ํ•ต์‹ฌ์ธ๋ฐ์š”. ์ฆ‰, O(1) ์‹œ๊ฐ„ ๋ณต์žก๋„๋กœ ํ•ด๋‹น ๊ธฐ๋Šฅ์„ ์ˆ˜ํ–‰ํ•ด์•ผ .. 2022. 9. 22.
[Algorithm] Floyd's Cycle Detection์ด๋ž€? (feat. Linked List) ์•ˆ๋…•ํ•˜์„ธ์š” Foma ์ž…๋‹ˆ๋‹ค! ์š”์ƒˆ LeetCode์—์„œ Linked List์˜ ์‚ฌ์ดํด์— ๊ด€๋ จ๋œ ๋ฌธ์ œ๋ฅผ ํ‘ธ๋Š”๋ฐ slow, fast ํฌ์ธํ„ฐ๋ฅผ ๋งŽ์ด ์ด์šฉํ•˜๋”๋ผ๊ตฌ์š”. ํ•ด๋‹น ํ’€์ด๊ฐ€ ์ดํ•ด๊ฐ€ ์•ˆ๋ผ์„œ ์ฐพ์•„ ๋ณด๋‹ˆ ๊ด€๋ จ๋œ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์žˆ์—ˆ๊ณ , ๊ทธ๊ฒƒ์ด Floyd's Cycle Detection ์ด์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์˜ค๋Š˜์€ ๋งํฌ๋“œ ๋ฆฌ์ŠคํŠธ์—์„œ ์‚ฌ์ดํด์ด ์žˆ๋Š”์ง€ ์—†๋Š”์ง€๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๊ณ , ํ•ด๋‹น ์‚ฌ์ดํด์˜ ์‹œ์ž‘์ ์ด ์–ด๋””์ธ์ง€ ์•Œ์•„๋‚ผ ์ˆ˜ ์žˆ๋Š” Floyd's Cycle Detection ์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๋ฐ”๋กœ ์‹œ์ž‘ํ• ๊ฒŒ์š”~ Floyd's Cycle Detection ์ด๋ž€? ๐Ÿ” Robert W. Floyd๊ฐ€ ๊ณ ์•ˆํ•œ ๋ฆฌ์ŠคํŠธ์˜ ์‚ฌ์ดํด์„ ๋น ๋ฅด๊ณ  ์ ์€ ๋ฉ”๋ชจ๋ฆฌ๋กœ ์ฐพ๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ž…๋‹ˆ๋‹ค. (Robert W. Floyd๋Š” ํ”Œ๋กœ์ด๋“œ ์™€์ƒฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ๋งŒ๋“ค.. 2022. 9. 18.
[Swift] 2022 KAKAO TECH INTERNSHIP ๋“ฑ์‚ฐ์ฝ”์Šค ์ •ํ•˜๊ธฐ Problem ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr Solution ํ•ด๋‹น ๋ฌธ์ œ๋Š” BFS ํ˜น์€ ๋‹ค์ต์ŠคํŠธ๋ผ๋ฅผ ์ด์šฉํ•˜์—ฌ ํ’€์–ด์•ผ ํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. 1. ํ˜„์žฌ ๊ฒฝ๋กœ์˜ ์ตœ๋Œ€ intensity์™€ ํ˜„์žฌ ์ง€์ ์˜ ์ •๋ณด๋ฅผ ๊ฐ–๋Š” Node๋ฅผ ๋งŒ๋“ค์–ด ์ค€๋‹ค. struct Node { let current: Int let maxIntensity: Int } 2. ํ•„์š”ํ•œ ๋ณ€์ˆ˜๋“ค์„ ์„ธํŒ…ํ•ด ์ค€๋‹ค. answer: ๊ฐ€์žฅ ์ ์€ intensity์˜ ์‚ฐ๋ด‰์šฐ๋ฆฌ์™€ ๊ฐ’์„ ์ €์žฅํ•  ๋ณ€์ˆ˜ connection: path์˜ ์—ฐ๊ฒฐ๋œ ์ •๋ณด๋ฅผ ์ €์žฅํ•  ๋ณ€์ˆ˜ summitDic: ์‚ฐ๋ด‰์šฐ๋ฆฌ๋ฅผ ์ €์žฅํ•  ๋”•์…”๋„ˆ๋ฆฌ gat.. 2022. 8. 29.
[Swift] 2022 KAKAO TECH INTERNSHIP ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ ๊ณต๋ถ€ Problem ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr Solution ํ•ด๋‹น ๋ฌธ์ œ๋Š” ๋‹ค์ด๋‚˜๋ฏน ํ”„๋กœ๊ทธ๋ž˜๋ฐ์œผ๋กœ ํ’€์–ด์•ผ ํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค. 1. ์•Œ๊ณ ๋ ฅ๊ณผ ์ฝ”๋”ฉ๋ ฅ์˜ ์ตœ๋Œ€์น˜๋ฅผ ๊ตฌํ•ด์ค€๋‹ค. ๋ฌธ์ œ๋ฅผ ๋ชจ๋‘ ํ’€ ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์€ ์•Œ๊ณ ๋ ฅ๊ณผ ์ฝ”๋”ฉ๋ ฅ์˜ ์ตœ๋Œ€์น˜๋ฅผ ์–ป๋Š” ๋‹ค๋Š” ๊ฒƒ์ด๋ฏ€๋กœ ๋ฏธ๋ฆฌ ๊ตฌํ•ด์ค€๋‹ค. var maxAlp: Int = alp var maxCop: Int = cop problems.forEach { maxAlp = max(maxAlp,$0[0]) maxCop = max(maxCop,$0[1]) } 2. dp ๋ฐฐ์—ด์„ ์•Œ๊ณ ๋ ฅ + 1 , ์ฝ”๋”ฉ๋ ฅ + 1๊ฐœ์˜ ์ด์ค‘ ๋ฐฐ์—ด์„ ๋งŒ๋“ค์–ด .. 2022. 8. 26.
[Swift] 2022 KAKAO TECH INTERNSHIP ๋‘ ํ ํ•ฉ ๊ฐ™๊ฒŒ ๋งŒ๋“ค๊ธฐ Problem ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr Solution ๋‚˜๋Š” ์ด๋ฒˆ ๋ฌธ์ œ๋ฅผ ์Šฌ๋ผ์ด๋”ฉ ์œˆ๋„์šฐ(Sliding-Window)๋ฅผ ์ด์šฉํ•ด์„œ ํ’€์—ˆ๋‹ค. 1. ํ•„์š”ํ•œ ๋ณ€์ˆ˜๋ฅผ ์„ธํŒ…ํ•œ๋‹ค. cumulativeSum: ๋ˆ„์ ํ•ฉ์„ ๋‹ด์„ ๋ฐฐ์—ด q1Length: queue1์˜ ๊ธธ์ด q2Length: queue2์˜ ๊ธธ์ด answer: ๊ฐ€์žฅ ์ ์€ ์ž‘์—… ํšŸ์ˆ˜๋ฅผ ๊ธฐ๋กํ•  ๋ณ€์ˆ˜ start: ์Šฌ๋ผ์ด๋”ฉ ์œˆ๋„์šฐ์—์„œ ์‹œ์ž‘ ์ง€์ ์„ ๊ฐ€๋ฅดํ‚ฌ ๋ณ€์ˆ˜ var cumulativeSum: [Int] = [0] let q1Length: Int = queue1.count let q2Length: I.. 2022. 8. 24.
[Swift] 2022 KAKAO TECH INTERNSHIP ์„ฑ๊ฒฉ ์œ ํ˜• ๊ฒ€์‚ฌํ•˜๊ธฐ Problem ํ•œ ๋™์•ˆ ๋ฆฟ์ฝ”๋“œ๋งŒ ํ’€๋‹ค๊ฐ€ ์ •๋ง ์˜ค๋žœ๋งŒ์— ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค๋ฅผ ๋“ค์–ด๊ฐ”๋”๋‹ˆ ์ƒˆ๋กœ์šด ์นด์นด์˜ค ๋ฌธ์ œ๊ฐ€ ์žˆ์–ด์„œ ํ•œ๋ฒˆ ํ’€์–ด๋ดค๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr Solution 1. ์ฃผ์–ด์ง„ ์„ฑ๊ฒฉ ์•ŒํŒŒ๋ฒณ์„ ๋”•์…”๋„ˆ๋ฆฌ๋กœ ๋งŒ๋“ค์–ด ์ค€๋‹ค. var charDic: [Character:Int] = ["R":0,"T":0,"C":0,"F":0,"J":0,"M":0,"A":0,"N":0] 2. survey๋ฅผ ์ˆœํšŒํ•˜๋ฉฐ choice์˜ ๊ฐ’์— ๋งž๊ฒŒ ์ฒซ ๋ฒˆ์งธ ๋˜๋Š” ๋‘ ๋ฒˆ์งธ ์บ๋ฆญํ„ฐ์— ๊ฐ’์„ ๋”ํ•ด์ค€๋‹ค. ๋งŒ์•ฝ choices์˜ i๋ฒˆ์งธ ๊ฐ’์ด 4๋ณด๋‹ค ์ž‘๋‹ค๋ฉด ์ฒซ ๋ฒˆ์งธ ๊ธ€์ž์— 4์—์„œ ํ•ด๋‹น.. 2022. 8. 23.
[Node.js] Prisma + MySQL ๋‹ค๋Œ€๋‹ค ๊ด€๊ณ„ ๋งŒ๋“ค๊ธฐ (MySQL Many to Many relationship using Prisma) ์•ˆ๋…•ํ•˜์„ธ์š” Foma ์ž…๋‹ˆ๋‹ค. ์š”์ฆ˜ ์ฑ„ํŒ…์•ฑ์„ ๋งŒ๋“ค๋ฉด์„œ ์œ ์ €์™€ ์ฑ„ํŒ…๋ฐฉ์˜ ๊ด€๊ณ„๋ฅผ ์„ค์ •ํ•ด์•ผ ํ•˜๋Š”๋ฐ ์กฐ๊ธˆ ๋ณต์žกํ•œ ๊ฒŒ ์žˆ๋”๋ผ๊ตฌ์š”. ๊ฐ„๋‹จํ•˜๊ฒŒ ์„ค๋ช…ํ•˜๋ฉด ์ฑ„ํŒ…์•ฑ์„ ๋งŒ๋“œ๋Š”๋ฐ User๋Š” ์—ฌ๋Ÿฌ ์ฑ„ํŒ…๋ฐฉ์„ ๊ฐ€์ ธ์•ผ ํ•˜๊ณ , ์ฑ„ํŒ…๋ฐฉ์€ ์—ฌ๋Ÿฌ ์œ ์ €๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋‹ค๋Œ€๋‹ค ๊ด€๊ณ„๋ฅผ ๋งŒ๋“ค๊ณ  ์‹ถ์—ˆ๋Š”๋ฐ์š”. ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•ด๋‹น ๋ชจ๋ธ๊ณผ ๊ด€๊ณ„๋ฅผ ์ •๋ฆฌํ•ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๋ฐ”๋กœ ์‹œ์ž‘ํ• ๊ฒŒ์š”~ Model User ์œ ์ € ๋ชจ๋ธ์€ ์•„๋ž˜์™€ ๊ฐ™์ด ๋งŒ๋“ค์–ด ์ค๋‹ˆ๋‹ค. model User { id String @id @default(uuid()) name String @unique profileImage String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } ChatRoom ์ฑ„ํŒ…๋ฐฉ ๋ชจ๋ธ์€ ์•„.. 2022. 8. 18.
[React Native] ์Šค์™€์ดํ”„ ํ•˜๋ฉด ์‚ญ์ œ ๋ฒ„ํŠผ ๋‚˜์˜ค๋Š” ์ปดํฌ๋„ŒํŠธ ๊ตฌํ˜„ํ•˜๊ธฐ (Swipeable Component with delete button) ์•ˆ๋…•ํ•˜์„ธ์š” Foma ์ž…๋‹ˆ๋‹ค. ์˜ค๋Š˜์€ React-Native์—์„œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์Šค์™€์ดํ”„ ํ–ˆ์„ ๋•Œ ์‚ญ์ œ ๋ฒ„ํŠผ์ด ๋‚˜์˜ค๋Š” ๊ธฐ๋Šฅ์„ ์ •๋ฆฌํ•ด ๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๋ฐ”๋กœ ์‹œ์ž‘ํ• ๊ฒŒ์š”~ Preview Install npm install --save react-native-gesture-handler Screen.tsx import {Swipeable, GestureHandlerRootView} from 'react-native-gesture-handler'; ์˜ค๋ฅธ์ชฝ์— ๋“ค์–ด๊ฐˆ Delete ๋ฒ„ํŠผ์„ ๋งŒ๋“ค์–ด ์ค๋‹ˆ๋‹ค. dragX๋ฅผ ๋ฐ›์•„์™€ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ ์šฉํ•˜๊ณ , id์— List์˜ index๋ฅผ ๋ฐ›์•„์™€ ๋ฒ„ํŠผ์„ ๋ˆŒ๋ €์„ ๋•Œ ํ•ด๋‹น index๋ฅผ ์ถœ๋ ฅํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. const renderRightActions = (dragX, index) => { co.. 2022. 8. 18.
[React Native] RTK-Query ํŒŒ๋ผ๋ฏธํ„ฐ์— ๋งž๊ฒŒ ํŠน์ • ๋ฐ์ดํ„ฐ๋งŒ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ(Get specific data by parameter using RTK-query) ์•ˆ๋…•ํ•˜์„ธ์š” Foma ์ž…๋‹ˆ๋‹ค. ์˜ค๋Š˜์€ RTK-Query์—์„œ ํŒŒ๋ผ๋ฏธํ„ฐ์— ๋งž๊ฒŒ ์›ํ•˜๋Š” ํŠน์ • ๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๋งŽ์€ ์‚ฝ์งˆ์„ ํ•˜๊ณ  ๊ฒฐ๊ตญ ํ•ด๊ฒฐ๋ฒ•์„ ์•Œ์•„๋‚ด๊ฒŒ ๋˜์–ด ๊ธ€๋กœ ์ •๋ฆฌํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๋ฐ”๋กœ ์‹œ์ž‘ํ• ๊ฒŒ์š”~ 1. ์ฒซ ๋ฒˆ์งธ ์‹œ๋„ ์šฐ์„  ์ œ๊ฐ€ ํ•˜๋ ค ํ–ˆ๋˜๊ฑด ์œ ์ €๋ฅผ ์ด๋ฆ„์œผ๋กœ ์กฐํšŒํ•ด์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๊ฒƒ์ด์—ˆ๋Š”๋ฐ์š”. ์•„๋ž˜์™€ ๊ฐ™์ด ์ฟผ๋ฆฌ๋ฅผ ํ†ตํ•ด์„œ ์—”๋“œํฌ์ธํŠธ๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. export const userAPISlice = createApi({ reducerPath: 'userAPI', baseQuery: fetchBaseQuery({baseUrl: 'http://192.168.111.34:3001/api'}), endpoints: builder => ({ ... getUserByName: builde.. 2022. 8. 12.
[React Native] useNavigation์™€ useRoute ์ด์šฉํ•ด์„œ ํ™”๋ฉด ์ด๋™ํ•˜๊ณ  ๋ฐ์ดํ„ฐ ์ „๋‹ฌํ•˜๊ธฐ (Move and Pass data between two screens using Hooks) ์•ˆ๋…•ํ•˜์„ธ์š” Foma ์ž…๋‹ˆ๋‹ค. ํ‰์†Œ์— ๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ์—์„œ navigation์„ props๋กœ ์ „๋‹ฌํ•˜๋Š” ๊ฒŒ ๋„ˆ๋ฌด ๋ถˆํŽธํ–ˆ๋Š”๋ฐ์š”. ์˜ค๋Š˜์€ React-Native์—์„œ navigation์„ props๋กœ ์ „๋‹ฌํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ, useNavigation๊ณผ useRoute๋ฅผ ๋งŒ๋“ค์–ด ์ค˜์„œ ํ™”๋ฉด์„ ์ด๋™๊ณผ ํ•จ๊ป˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•˜๊ณ  ๋ฐ›์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๋ฐ”๋กœ ์‹œ์ž‘ํ• ๊ฒŒ์š”~ Install npm install @react-navigation/native npm install @react-navigation/native-stack npm install @react-navigation/stack npm install react-native-safe-area-context Navigation Navigation/index.ts ๊ธฐ์กด Pro.. 2022. 8. 12.
[React Native] ChatApp Socket.io Room ์ ์šฉํ•˜๊ธฐ (feat. TypeScript) ์•ˆ๋…•ํ•˜์„ธ์š” Foma ์ž…๋‹ˆ๋‹ค. ์ €๋ฒˆ ๊ธ€์—์„œ Node.js์—์„œ Socket.io๋ฅผ ์ด์šฉํ•˜์—ฌ Room์„ ๋งŒ๋“ค์–ด ๋ณด์•˜๋Š”๋ฐ์š”. (ํ˜น์‹œ ์•ˆ๋ณด์‹  ๋ถ„๋“ค์€ ์—ฌ๊ธฐ ์—์„œ ํ™•์ธํ•ด ์ฃผ์„ธ์š”!) ์˜ค๋Š˜์€ ๋ฐฑ์—”๋“œ ์„œ๋ฒ„์—์„œ ์˜จ ๋ฐ์ดํ„ฐ๋ฅผ ํ”„๋ก ํŠธ์— ์ ์šฉํ•ด ๋ณด๋Š” ๊ณผ์ •์„ ์ •๋ฆฌํ•ด ๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๋ฐ”๋กœ ์‹œ์ž‘ํ• ๊ฒŒ์š”~ Preview Install npm install @react-navigation/native npm install @react-navigation/native-stack npm install react-native-screens npm install react-native-safe-area-context npm install socket.io-client ScreenEnums ์Šคํฌ๋ฆฐ ์ข…๋ฅ˜๋ฅผ Enum์œผ๋กœ ๋งŒ๋“ค์–ด ๋†“์Šต๋‹ˆ๋‹ค. export .. 2022. 8. 10.
[Node.js] Socket.io๋กœ Room ๊ตฌํ˜„ํ•˜๊ธฐ (feat. TypeScript) ์•ˆ๋…•ํ•˜์„ธ์š” Foma ์ž…๋‹ˆ๋‹ค. ์˜ค๋Š˜์€ Socket.io๋ฅผ ์ด์šฉํ•˜์—ฌ Room์„ ๊ตฌํ˜„ํ•ด ํŠน์ • Room์— ์žˆ๋Š” ์œ ์ €๋“ค์—๊ฒŒ๋งŒ ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋„๋ก ๊ตฌํ˜„ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋ฐ”๋กœ ์‹œ์ž‘ํ• ๊ฒŒ์š”~ Preview Install typescript, ts-node, express, socket.io ๋ฅผ ์„ค์น˜ํ•ด ์ค๋‹ˆ๋‹ค. npm install typescript npm install ts-node npm install express npm install socket.io npm install @types/express npm install @types/socket.io Model ๋ฉ”์„ธ์ง€ ๋ชจ๋ธ์„ ๋งŒ๋“ค์–ด ์ค๋‹ˆ๋‹ค. export interface Message { type: string; user: string; message: str.. 2022. 8. 10.
728x90
๋ฐ˜์‘ํ˜•