[React/Axios] axios delete ์š”์ฒญ ์‹œ body์— data ๋„ฃ๋Š” ๋ฐฉ๋ฒ•
ยท
Frontend/React
๐Ÿšจ ์˜ค๋ฅ˜ ๋ฐœ์ƒ AxiosError message: 'Request failed with status code 400' axios.delete(`${url}/unlike`, { projectId: id, }) axios์˜ delete๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„œ๋ฒ„์— ์š”์ฒญ์„ ํ•  ๋•Œ, ๋‹ค์Œ๊ณผ ๊ฐ™์ด data๋ฅผ ์ „๋‹ฌํ•˜๋ฉด ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. ๐Ÿ’ก ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• axios.delete๋Š” request body๋ฅผ ์ง€์›ํ•˜๋ฉฐ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋‘๊ฐœ์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ํ—ˆ์šฉํ•œ๋‹ค. axios.delete(url[, config]) ๐Ÿ‘ config.data๋Š” request body๋ฅผ ์„ค์ •ํ•˜๋Š”๋ฐ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. axios.delete(`${url}/unlike`, { data: { projectId: id, }, }) 2๋ฒˆ์งธ ์ธ์ž์—์„œ data๋ฅผ data: {}..
[JavaScript] ํ•œ๋ฒˆ์— ํ•˜๋Š” ๋ฐฐ์—ด ์ƒ์„ฑ & ์ดˆ๊ธฐํ™”
ยท
Frontend/JavaScript
JavaScript์˜ ๋ฐฐ์—ด(Array)๋Š” ๊ฐ์ฒด(ํ•จ์ˆ˜)๋‹ค. ๋”ฐ๋ผ์„œ, ๋Œ€ํ‘œ์  ๊ฐ์ฒด์ง€ํ–ฅ ์–ธ์–ด์ธ ์ž๋ฐ”์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ new Array()๊ฐ€ ์กด์žฌํ•œ๋‹ค. ๋ฐฐ์—ด์˜ ์ƒ์„ฑ์ž(new Array())์™€ ํ•˜๋‚˜์˜ ์ˆซ์ž ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ๊ทธ ๊ฒฐ๊ณผ๋Š” length๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๊ณ , ๊ธธ์ด๋งŒํผ์˜ ๋นˆ ์Šฌ๋กฏ์„ ๊ฐ€์ง„ ๋ฐฐ์—ด์ด๋‹ค. ๋ฐฐ์—ด์˜ ์ดˆ๊ธฐ๊ฐ’์„ ํ™•์ธํ•ด๋ณด๋ฉด undefined๊ฐ€ ์ถœ๋ ฅ๋˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. let datas = new Array(5) console.log(datas[0]) // undefined console.log(datas.length) // 5 ์•„๋ž˜์™€ ๊ฐ™์ด new Array()์˜ ๋งค๊ฐœ๋ณ€์ˆ˜์— ์›ํ•˜๋Š” ์ดˆ๊ธฐ๊ฐ’๋“ค์„ ๋„˜๊ฒจ์ฃผ๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ์ƒ์„ฑ๊ณผ ์ดˆ๊ธฐํ™”๋ฅผ ๋™์‹œ์— ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ๋ฐฐ์—ด์˜ ๊ธธ์ด์— ๋”ฐ๋ผ ํ•œ๊ณ„๊ฐ€ ์กด์žฌํ•œ๋‹ค. // new Ar..
[CSS] ๋ฐ˜์‘ํ˜• ํ—ค๋” ๋งŒ๋“ค๊ธฐ (feat. mediaQuery)
ยท
Frontend/CSS
CSS์˜ mediaQuery๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ทฐํฌํŠธ(viewport) ๋„ˆ๋น„์— ๋”ฐ๋ผ CSS ์†์„ฑ ๊ฐ’์„ ๋ณ€๊ฒฝํ•ด๋ณด์žโ— ๐Ÿ“Œ mediaQuery๋ž€ ๋ฌด์—‡์ธ๊ฐ€์š”? ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ(mediaQuery)๋Š” ๋‹จ๋ง๊ธฐ์˜ ์œ ํ˜• (์ถœ๋ ฅ๋ฌผ vs. ํ™”๋ฉด)๊ณผ, ์–ด๋–ค ํŠน์„ฑ์ด๋‚˜ ์ˆ˜์น˜ (ํ™”๋ฉด ํ•ด์ƒ๋„, ๋ทฐํฌํŠธ ๋„ˆ๋น„ ๋“ฑ)์— ๋”ฐ๋ผ ์›น ์‚ฌ์ดํŠธ๋‚˜ ์•ฑ์˜ ์Šคํƒ€์ผ์„ ์ˆ˜์ •ํ•  ๋•Œ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. if ์กฐ๊ฑด๋ฌธ๊ณผ ๋น„์Šทํ•œ ๊ฐœ๋…์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ์ดํ•ดํ•˜๊ธฐ ์‰ฝ์Šต๋‹ˆ๋‹ค. ex) ๋ทฐํฌํŠธ ๋„ˆ๋น„๊ฐ€ 62rem ์ดํ•˜์ด๋ฉด flex-direction์„ row์—์„œ column์œผ๋กœ ๋ฐ”๊ฟ”์ค˜~ @media ํ‚ค์›Œ๋“œ๋กœ ์‹œ์ž‘ํ•˜๋Š” ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ์˜ ๋ฌธ๋ฒ• ๊ตฌ์กฐ @media (์กฐ๊ฑด) { ์Šคํƒ€์ผ } ์Šคํƒ€์ผ ๋ถ€๋ถ„์—๋Š” ์ผ๋ฐ˜์ ์ธ CSS ์ฝ”๋“œ๊ฐ€ ๋“ค์–ด๊ฐ€๋Š”๋ฐ, ์กฐ๊ฑด ๋ถ€๋ถ„์ด ๋งŒ์กฑ๋  ๋•Œ๋Š” ์Šคํƒ€์ผ์ด ์ ์šฉ๋˜๊ณ , ๋งŒ์กฑ๋˜์ง€ ์•Š์„ ๋•Œ๋Š” ์Šคํƒ€์ผ..
[VS code] React ์œ ์šฉํ•œ ๊ฐœ๋ฐœ Tools ๋ฐ Extension ์„ค์น˜
ยท
Frontend/VS Code
๐Ÿ“Œ Tools React Developer Tools๋ฅผ ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜๋ฉด, ํฌ๋กฌ ์›น ๋ธŒ๋ผ์šฐ์ €์—์„œ ๊ฐœ๋ฐœ์ž ๋ชจ๋“œ(F12)๋กœ ์ปดํฌ๋„ŒํŠธ ๊ตฌ์กฐ๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๊ณ  ๋ณ€๊ฒฝํ•˜๋ฉด์„œ ํ…Œ์ŠคํŠธํ•˜๊ธฐ์— ์šฉ์ดํ•˜๋‹ค. (์‚ฌ์šฉ ๊ถŒ์žฅ๐Ÿ‘) https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi React Developer Tools Adds React debugging tools to the Chrome Developer Tools. Created from revision 336ac8ceb on 7/13/2022. chrome.google.com ๐Ÿ“Œ Extension Reactjs Code Snippets rcc + tab, rsi..
[JavaScript] ์Šค์ฝ”ํ”„(Scope)๋ž€ ๋ฌด์—‡์ธ๊ฐ€?
ยท
Frontend/JavaScript
์Šค์ฝ”ํ”„(Scope) โ“ 1๏ธโƒฃ ๋ณ€์ˆ˜๋ฅผ ์ฐธ์กฐํ•  ์ˆ˜ ์žˆ๋Š” ์œ ํšจ ๋ฒ”์œ„ 2๏ธโƒฃ ์‹๋ณ„์ž(๋ณ€์ˆ˜, ํ•จ์ˆ˜, ํด๋ž˜์Šค ์ด๋ฆ„) ์ ‘๊ทผ ๊ทœ์น™์— ๋”ฐ๋ฅธ ์œ ํšจ ๋ฒ”์œ„ ๋ฒ”์œ„(์Šค์ฝ”ํ”„)๋Š” ์ค‘๊ด„ํ˜ธ(๋ธ”๋ก) ๋˜๋Š” ํ•จ์ˆ˜์— ์˜ํ•ด ๋‚˜๋ˆ ์ง„๋‹ค. ์Šค์ฝ”ํ”„์˜ ์ฃผ์š” ๊ทœ์น™ โ— ๐Ÿ‘‰ ๊ทœ์น™ 1. ๋ธ”๋Ÿญ ์•ˆ์˜ ๋ณ€์ˆ˜๋Š” ๋ธ”๋Ÿญ ์•ˆ์—์„œ๋งŒ ์œ ํšจํ•˜๋‹ค. ๋ฐ”๊นฅ์ชฝ ์Šค์ฝ”ํ”„์—์„œ ์„ ์–ธํ•œ ์‹๋ณ„์ž๋Š” ์•ˆ์ชฝ ์Šค์ฝ”ํ”„์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅ ๋ฐ˜๋ฉด, ์•ˆ์ชฝ์—์„œ ์„ ์–ธํ•œ ์‹๋ณ„์ž๋Š” ๋ฐ”๊นฅ์ชฝ ์Šค์ฝ”ํ”„์—์„œ๋Š” ์‚ฌ์šฉํ•  ์ˆ˜ โŒ ๋ธ”๋Ÿญ ๋‚ด๋ถ€์—์„œ๋งŒ ์กด์žฌํ•˜๊ณ , ๋ธ”๋Ÿญ์ด ๋๋‚˜๋ฉด ๊ฐ€๋น„์ง€ ์ปฌ๋ ‰ํ„ฐ(GC)์— ์˜ํ•ด ์ž๋™์œผ๋กœ ์†Œ๋ฉธ๋œ๋‹ค. const a = 1; { const b = 2; console.log(a); } console.log(b); // ์˜ค๋ฅ˜ ๋ฐœ์ƒ(app crashed) ๐Ÿ‘‰ ๊ทœ์น™ 2. ์ „์—ญ ์Šค์ฝ”ํ”„ vs ์ง€์—ญ ์Šค์ฝ”ํ”„ ๊ฐ€์žฅ ๋ฐ”๊นฅ์ชฝ์˜ ์Šค์ฝ”ํ”„๋ฅผ ์ „..
[JavaScript] ํด๋กœ์ €๋ž€ ๋ฌด์—‡์ธ๊ฐ€?
ยท
Frontend/JavaScript
ํด๋กœ์ € โ“ ํ•จ์ˆ˜์™€ ํ•จ์ˆ˜๊ฐ€ ์„ ์–ธ๋œ ์–ดํœ˜์  ํ™˜๊ฒฝ์˜ ์กฐํ•ฉ ์ด ํ™˜๊ฒฝ์€ ํด๋กœ์ €๊ฐ€ ์ƒ์„ฑ๋œ ์‹œ์ ์˜ ์œ ํšจ ๋ฒ”์œ„ ๋‚ด์— ์žˆ๋Š” ๋ชจ๋“  ์ง€์—ญ ๋ณ€์ˆ˜๋กœ ๊ตฌ์„ฑ๋œ๋‹ค. ์ฆ‰, ๋‚ด๋ถ€ ํ•จ์ˆ˜์—์„œ ์™ธ๋ถ€ ํ•จ์ˆ˜์— ์žˆ๋Š” ์ƒํƒœ์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š” ๊ถŒํ•œ์„ ๋ถ€์—ฌํ•œ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ์™œ ์‚ฌ์šฉํ• ๊นŒ โ“ ๋‚ด๋ถ€ ์ •๋ณด๋ฅผ ์€๋‹‰ํ•˜๊ณ , ๊ณต๊ฐœ ํ•จ์ˆ˜(public ๋˜๋Š” ์™ธ๋ถ€)๋ฅผ ํ†ตํ•œ ๋ฐ์ดํ„ฐ ์กฐ์ž‘์„ ์œ„ํ•ด ์‚ฌ์šฉํ•œ๋‹ค. (์บก์Šํ™”, ์ •๋ณด์€๋‹‰) ์ „์—ญ๋ณ€์ˆ˜ ๋˜ํ•œ ์ค„์—ฌ์ง€๊ฒŒ ๋˜๋ฏ€๋กœ ๊ฐœ๋ฐœ ๊ณผ์ •์—์„œ ์‹ค์ˆ˜๋กœ ์ ‘๊ทผํ•˜๋Š” ์ผ์ด ์•ˆ์ƒ๊ธด๋‹ค. ํ˜„์žฌ๋Š” ํด๋ž˜์Šค์—์„œ์˜ private ํ•„๋“œ ๋˜๋Š” ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค. ์–ด๋–ป๊ฒŒ ์ด๊ฒƒ์ด ๊ฐ€๋Šฅํ• ๊นŒ โ“ inner ๋ ‰์‹œ์ปฌ ํ™˜๊ฒฝ์ด ์™ธ๋ถ€ ๋ ‰์‹œ์ปฌ ํ™˜๊ฒฝ์„ ์ฐธ์กฐํ•˜๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ํด๋กœ์ €๋ฅผ ์ž˜ ์ดํ•ดํ•˜๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ๋ณ€์ˆ˜์˜ ์œ ํšจ๋ฒ”์œ„๋ฅผ ์ง€์ •ํ•˜๋Š”์ง€(Lexical scoping)๋ฅผ ๋จผ์ € ์ดํ•ดํ•ด์•ผ ํ•œ๋‹ค...
[React Native] ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜์—ฌ ํ˜„์žฌ ํ™”๋ฉด์„ ์บก์ฒ˜ํ•ด๋ณด์žโ—
ยท
Frontend/React Native
Install $ yarn add react-native-view-shot Import import ViewShot from 'react-native-view-shot'; Code import ViewShot from 'react-native-view-shot'; function App() { const ref = useRef(); const captureScreen = () => { ref.current.capture().then((uri) => { console.log('capture complete...', uri); }); }; return ( // ํ™”๋ฉด ์บก์ฒ˜๋  ๋ถ€๋ถ„์„ ViewShot ์ปดํฌ๋„ŒํŠธ๋กœ ๊ฐ์‹ธ์ค€๋‹คโ—โ— ํ™”๋ฉด ์บก์ฒ˜ ); } ๐Ÿ’ก useRef useRef๋Š” ํŠน์ • ์ปดํฌ๋„ŒํŠธ๋ฅผ ์„ ํƒํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ho..
[React Native] ํ‚ค๋ณด๋“œ๊ฐ€ TextInput์ฐฝ์„ ์•ˆ ๊ฐ€๋ฆฌ๋„๋ก ํ•ด๋ณด์ž! (KeyboardAwareScrollView)
ยท
Frontend/React Native
์ปค๋ฎค๋‹ˆํ‹ฐ ์ƒ์„ธํŽ˜์ด์ง€๋ฅผ ๋งŒ๋“œ๋Š” ๊ณผ์ •์—์„œ TextInput์ฐฝ์ด ์Šคํฌ๋ฆฐ์˜ ๋งจ ๋ฐ‘์— ์œ„์น˜ํ•˜๋„๋ก ํ•˜์˜€๋‹ค. ์•ฑ์œผ๋กœ ๊ฐœ๋ฐœ์„ ์ฒ˜์Œํ•ด๋ณด๋‹ˆ ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒผ๋‹ค. ํ‚ค๋ณด๋“œ๋ฅผ ๋„์šฐ๋ฉด TextInput์ฐฝ์„ ๋ฎ์–ด ๋ฌด์—‡์„ ์ž…๋ ฅํ•˜๋Š”์ง€ ๋ณผ ์ˆ˜๊ฐ€ ์—†๊ฒŒ ๋œ ๊ฒƒ์ด๋‹ค. ํ‚ค๋ณด๋“œ๊ฐ€ TextInput์ฐฝ์„ ์•ˆ๊ฐ€๋ฆฌ๋„๋ก ํ•˜๊ณ  ํฌ์ปค์‹ฑ์ด ๋˜๋„๋ก ํ•ด๋ณด์žโ—โ— 1๏ธโƒฃ react-native-keyboard-aware-scroll-view ๋ชจ๋“ˆ ์„ค์น˜ npm i react-native-keyboard-aware-scroll-view --save 2๏ธโƒฃ import๋ฌธ import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'; 3๏ธโƒฃ ๋ณธ๋ฌธ ๋‚ด์šฉ์„ KeyboardAwareSc..
_์„ฑํ˜ธ_
'Frontend' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (2 Page)