묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨한 번에 끝내는 자바스크립트: 바닐라 자바스크립트로 SPA 개발까지
select값이 출력이 안돼요
input 값은 나오는데 select 값은 출력이 안돼요 ㅠ 오류 메세지도 따로 나오는 건 없고 console.log로 cities 값을 볼려고 했는데 빈 Array가 나옵니다 ㅠ import Header from "./components/Header.js"; import RegionList from "./components/RegionList.js"; import CityDetail from "./components/CityDetail.js"; import CityList from "./components/CityList.js"; import { request } from "./components/api.js"; export default function App($app){ const getSortBy = () => { if (window.location.search){ return window.location.search.split('sort=')[1].split('&')[0]; } return 'total'; }; const getSearchWorld = () => { if(window.location.search && window.location.search.includes('search=')){ return window.location.search.split('search=')[1] } //뒤에 있는 값을 반환 return ''; }; this.state={ startIdx : 0, sortBy : getSortBy(), searchWorld: getSearchWorld(), region: '', cities:'', }; const header = new Header({ $app, initialState:{ sortBy:this.state.sortBy, searchWorld:this.state.searchWorld }, handleSortChange: async(sortBy) => { const pageUrl = `/${this.state.region}?sort=${sortBy}`; history.pushState( null, null, this.state.searchWorld ? pageUrl + `&search=${this.state.searchWorld}` : pageUrl ); //변경된 정렬기준을 적용한 새로운 데이터를 불러옴 (매개변수로 전달받은 새로운 정렬기준인 sortBy 값을 넣어야함) const cities = await request(0, this.state.region, sortBy, this.state.searchWorld); console.log(cities) // 변경된 상태값을 업데이트 this.setState({ ...this.state, startIdx:0, sortBy: sortBy, cities: cities, }); }, handleSearch: async(searchWorld) => { //웹사이트 주소를 알맞게 변경 history.pushState( null, null, `/${this.state.region}?sort=${this.state.sortBy}&search=${searchWorld}` ); const cities = await request(0, this.state.region, this.state.sortBy, searchWorld); this.setState({ ...this.state, startIdx:0, searchWorld: searchWorld, cities: cities }) }, }); const regionList = new RegionList(); const cityList = new CityList({ $app, initialState:this.state.cities, // 아래는 더보기 버튼을 눌렀을 때 실행되는 것 handleLoadMore: async() => { const newStartIdx = this.state.startIdx + 40; const newCities = await request(newStartIdx, this.state.sortBy, this.state.region, this.state.searchWorld); this.setState({ ...this.state, startIdx : newStartIdx, cities:{ cities:[...this.state.cities.cities, ...newCities.cities], isEnd: newCities.isEnd, } }) } }); const cityDetail = new CityDetail(); this.setState = (newState) => { this.state = newState; cityList.setState(this.state.cities); header.setState({sortBy:this.state.sortBy, searchWorld:this.state.searchWorld}); }; const init = async() => { const cities = await request(this.state.startIdx, this.state.sortBy, this.state.region, this.state.searchWorld); this.setState({ ...this.state, cities: cities, //api 호출의 결과인 cities }); }; init(); }
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
nestjs routing 질문있습니다.
controller에서 /test/:id라는 숫자를 받는 get 엔드포인트가 있고/test/info라는 정보를 주는 routing을 만들고 싶은데 test/info라고 호출하면 test/:id로 들어가더라구요 이걸 해결할 수 있는 방법이 있을까요?
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
repository생성후 반환 함수 관련 문의
안녕하세요181강에서 보면 리포지토리를 save 메서드로 생성한다음 반환해줄때 다시 찾아서 반환해주는데 실제 프로젝트 구현시도 이런식으로 해야되는건가요? 그냥 save() 메서드의 리턴을 await 로 변수에 받은다음 그 변수를 반환하면 안되나요?181강 메세지 보내기 마무리하기
-
미해결비전공자를 위한 풀스택 맛집지도 만들기 프로젝트!: Front, Back-end 그리고 배포까지
Putty에서 nginx를 vi로 수정할때 오류
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 제목과 같이 putty 터미널에서 vi로 vi /etc/nginx/sites-.../에서 수정하는데 저는 다음과 같은 화면이 나옵니다. ㅠㅠ 이거 왜 이런건가요
-
미해결비전공자를 위한 풀스택 맛집지도 만들기 프로젝트!: Front, Back-end 그리고 배포까지
mysql과 선생님의 깃허브 코드연결
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 안녕하세요선생님께서 올리신 완성본 코드를 깃허브에서 다운받아서 결과를 보고싶은데, 지도상에 음식점들의 핀이 뜨지 않습니다 ㅠ 아마 sql상에 더미 데이터들이랑 연결이 안되어서 그런것같은데 지도상에 마커들이 뜨게 하려면 어떻게 해야할까요 도와주세요
-
미해결비전공자를 위한 풀스택 맛집지도 만들기 프로젝트!: Front, Back-end 그리고 배포까지
nodemon 실행오류
[nodemon] 3.1.7[nodemon] to restart at any time, enter rs[nodemon] watching path(s): .[nodemon] watching extensions: js,mjs,cjs,json[nodemon] starting node index.js[nodemon] app crashed - waiting for file changes before starting... 다음과 같은 오류가 발생하는데 어떻게 해결해야하나요 ㅠ
-
미해결TailwindCSS 완벽 마스터: 포트폴리오부터 어드민까지!
스니펫 관련질문
이거 근데 log이렇게 치면console.log(''); 이렇게 되야되는거 아닌가요? 이상하게 안되네요console.log(); 이렇게 밖에 스니펫이 안되는데 '$1' 에서 '' 이부분은 왜 씹히는거죵?ㅠㅠ
-
미해결인터랙티브 웹 개발 제대로 시작하기
animation이벤트 질문이요!
window를 ballElem로 변경하면 click했을때 작동을 하지 않는데 이유를 모르겠습니다..!<script> const ballElem=document.querySelector('.ball'); window.addEventListener('click', function(){ ballElem.style.animation='ball-ani 1s 3 forwards'; }); ballElem.addEventListener('animationend',function(){ ballElem.classList.add('end'); }); ballElem.addEventListener('animationiteration',function(){ console.log('반복'); }); </script>
-
해결됨한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
비주얼스튜디오 파일, 폴더명에 대해 질문있습니다.
안녕하세요 리액트를 공부하기 위해 어제 처음 등록을 했서 잘 듣고 있습니다. 강의에 대한 질문은 아니지만 수업준비관련해서 비주얼스튜디오 부분에 대해 질문이 있는데 제가 현재 맥북으로 사용하고 외장하드를 연결해서 이 외장하드에 폴더를 만들어 사용하고 있는데 어느순간 파일을 만들거나 리액트를 설치할때 파일명앞에 이미지처럼 ._ 이런식으로 붙더라구요. 삭제하면 또 생겨서 구글링을 통해 찾아봤지만 해결이 되지 않았습니다. 혹시 방법이 없을까요?
-
미해결한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
npm init 을 터미널에 입력하면 사진과 같은 오류가 납니다.
3.3)Node.js 사용하기강의 3분10초입니다.npm init 을 터미널에 입력하면 사진과 같은 오류가 납니다.
-
미해결실무에 바로 적용하는 프런트엔드 테스트 - 2부. 테스트 심화: 시각적 회귀・E2E 테스트
브랜치 git clone 질문
질문 git clone https://github.com/practical-fe-testing/test-example-shopping-mall.git 를 했는데 폴더안에 gitignore 과 readme 파일만 있는데 해당 브랜치를 clone해서 사용하는게 아닌건가요? 참고사항 대체방안으로 zip파일로 다운받아서 사용하고 있긴합니다!
-
미해결자바스크립트 알고리즘 문제풀이 입문(코딩테스트 대비)
코드리뷰 부탁드립니다.
Map과 for문으로 풀이를 했는데, 코드리뷰 부탁드립니다. function solution(arr) { let sumSet = new Map(); for (let i = 0; i < arr.length; i++) { let sum = 0; for (let j = 0; j < String(arr[i]).length; j++) { sum += Number(String(arr[i])[j]); } sumSet.set(arr[i], sum); } let maxVal = 0; let maxKey = 0; for (const [key, value] of sumSet) { if (value > maxVal) { maxKey = key; maxVal = value; } else if (value === maxVal) { if (key > maxKey) { maxKey = key; maxVal = value; } } } return maxVal; } console.log(solution([128, 460, 603, 40, 521, 137, 123]));
-
해결됨한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
Home이 화면에 안 떠요
import "./App.css"; import { Routes, Route } from "react-router-dom"; import Home from "./pages/Home"; import Diary from "./pages/Diary"; import New from "./pages/New"; // 1. "/" : 모든 일기를 조회하는 Home 페이지 // 2. "/new" : 새로운 일기를 작성하는 New 페이지 // 3. "/diary" : 일기를 상세히 조회하는 Diary 페이지 function App() { return ( <Routes> <Route path="/" element={<Home />} /> <Route path="/new" element={<New />} /> <Route path="/diary" element={<Diary />} /> </Routes> ); } export default App; const Home = () => { return <div>Home</div>; }; export default Home;이렇게 작성했고, 오타도 없는 것 같은데 화면에 home이라는 글자가 안 뜹니다. router도 6.28. 으로 설치됐습니다.
-
해결됨Azure Native로 나만의 GPT 만들기
API와 DB연결
안녕하세요,API와 DB 연결을 다루는 강의를 시청 중 강의 11분 50초 정도에 웹소켓 연결이 안 되는 문제가 생겨 질문 드립니다!코드를 전부 똑같이 따라 작성하고 있음에도 왜 localhost 7071로 경로 수정 후 연결이 되지 않는지 모르겠습니다..해결 방안이 있을지 여쭙고 싶습니다!
-
해결됨[코드캠프] 시작은 프리캠프
정렬 연습중인데 왜 여성과 남성 칸이 가로로 배열 안되는지 모르겠습니다.
css:*{ box-sizing: border-box;}.box2{display: flex;align-items: center;margin: 10px auto;flex-direction: column;justify-content: space-evenly;}.box {width: 300px;height: 1px;border: 1px solid rgb(199, 199, 199);display: flex;flex-direction: column;justify-content: space-evenly;align-items: center;padding: 30px;margin: 5px auto;border-top-left-radius: 10px;border-top-right-radius: 10px;border-bottom-right-radius: 10px;border-bottom-left-radius: 10px;}.box3 {display: flex;flex-direction: row;justify-content: row;}select {border: 1px solid black;}.pb{width: 500px;height: 800px;border: 1px solid gray;display: flex;flex-direction: column;justify-content: space-around;align-items: center;padding: 30px;border-top-left-radius: 10px;border-top-right-radius: 10px;border-bottom-right-radius: 10px;border-bottom-left-radius: 10px;} html:<!DOCTYPE html><html lang="en"><head><title>회원가입</title><link href="./02-signup.css" rel="stylesheet" /></head><body><div class="pb"><h2 class="box2">회원가입</h2><input type="text" placeholder="이메일을 입력해주세요"class="box"><br><br><input type="text" placeholder="이름을 입력해주세요"class="box"><br><br><input type="password" placeholder="비밀번호를 입력해주세요" class="box"><br><br><input type="password" placeholder="비밀번호를 다시 입력해주세요" class="box"><br><br><select><option disabled="true" selected="true">지역을 선택하세요</option><option>서울</option><option>경기</option><option>인천</option></select><br><br><input type="radio" name="gender" class="box3"><span class="box3">여성</span><input type="radio" name="gender" class="box3"><span class="box3">남성</span><br><br><input type="checkbox"> 이용약관 동의합니다<hr><button class="box">가입하기</button></div><!-- <input type="button" value="가입하기2"> 예전에 사용했으나 커스텀하기 어려웠음 --></body></html> 어디가 문제 인지 알려주시면 감사하겠습니다.
-
해결됨한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
수업 질문입니다.
안녕하세요. 해당 강좌로 도움을 많이 받고 있습니다만,강좌에서는 redux을 이용한 상태관리 없는거 같더구요 .실무에서 redux를 많이 사용하느것 같은데요,혹시 추가 적으로 redux 강좌나 추가 업데이트 계획이 있으신지 문의 드립니다.아님 다른 이정환님의 한입 강좌 중에서 들을 수 있는지요?
-
해결됨한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
12.11 invalid Date 오류
따라서 하고 있었는데 다음 그림과 같이 invalid Date 라는 값이 떠서 관련 질문 드립니다. 강의 몇번 돌려보면서 오타가 있나 봤는데 도저히 모르겠어서 질문 드립니다...// App.jsx import "./App.css"; import { Routes, Route, Link, useNavigate } from "react-router-dom"; import Home from "./pages/Home"; import Diary from "./pages/Diary"; import New from "./pages/New"; import Edit from "./pages/Edit"; import Notfound from "./pages/Notfound"; import { useReducer, useRef, createContext } from "react"; const mockData = [ { id: 1, createdDate: new Date("2024-11-13").getTime(), emotionId: 1, content: "1번 일기 내용", }, { id: 2, createdDate: new Date("2024-11-10").getTime(), emotionId: 2, content: "2번 일기 내용", }, { id: 3, createdDate: new Date("2024-10-11").getTime(), emotionId: 3, content: "3번 일기 내용", }, ]; function reducer(state, action) { switch (action.type) { case "CREATE": return [action.data, ...state]; case "UPDATE": return state.map((item) => String(item.id) === String(action.data.id) ? action.date : item ); case "DELETE": return state.filter((item) => String(item.id) !== String(action.id)); default: return state; } } export const DiaryStateContext = createContext(); export const DiaryDispatchContext = createContext(); function App() { const [data, dispatch] = useReducer(reducer, mockData); const idRef = useRef(3); const onCreate = (createdDate, emotionId, content) => { dispatch({ type: "CREATE", data: { id: idRef.current++, createdDate, emotionId, content, }, }); }; const onUpdate = (id, createdDate, emotionId, content) => { dispatch({ type: "UPDATE", data: { id, createdDate, emotionId, content, }, }); }; const onDelete = (id) => { dispatch({ type: "DELETE", id, }); }; return ( <> <DiaryStateContext.Provider value={data}> <DiaryDispatchContext.Provider value={{ onCreate, onDelete, onUpdate }}> <Routes> <Route path="/" element={<Home />} /> <Route path="/new" element={<New />} /> <Route path="/diary/:id" element={<Diary />} /> <Route path="/edit/:id" element={<Edit />} /> <Route path="*" element={<Notfound />} /> </Routes> </DiaryDispatchContext.Provider> </DiaryStateContext.Provider> </> ); } export default App; //Home.jsx import { useState, useContext } from "react"; import { DiaryStateContext } from "../App"; import DiaryList from "../components/DiaryList"; import Header from "../components/Header"; import Button from "../components/button"; const getMonthlyData = (pivotDate, data) => { const beginTime = new Date( pivotDate.getFullYear(), pivotDate.getMonth(), 1, 0, 0, 0 ).getTime(); const endTime = new Date( pivotDate.getFullYear(), pivotDate.getMonth() + 1, 0, 23, 59, 59 ).getTime(); return data.filter( (item) => beginTime <= item.createdDate && item.createdDate <= endTime ); }; const Home = () => { const data = useContext(DiaryStateContext); const [pivotDate, setPivotDate] = useState(new Date()); const monthlyData = getMonthlyData(pivotDate, data); console.log(monthlyData); const onIncreaseMonth = () => { setPivotDate(new Date(pivotDate.getFullYear(), pivotDate.getMonth() + 1)); }; const onDecreaseMonth = () => { setPivotDate(new Date(pivotDate.getFullYear(), pivotDate.getMonth() - 1)); }; return ( <div> <Header title={`${pivotDate.getFullYear()}년 ${pivotDate.getMonth() + 1}월`} leftChild={<Button onClick={onDecreaseMonth} text={"<"} />} rightChild={<Button onClick={onIncreaseMonth} text={">"} />} /> <DiaryList data={monthlyData} /> </div> ); }; export default Home; //diaryList.jsx import Button from "./button"; import "./DiaryList.css"; import DiaryItem from "./DiaryItem"; const DiaryList = ({ data }) => { return ( <div className="DiaryList"> <div className="menu_bar"> <select> <option value={"latest"}>최신순</option> <option value={"oldest"}>오래된 순</option> </select> <Button text={"새 일기 쓰기"} type={"POSITIVE"} /> </div> <div className="list_wrapper"> {data.map((item) => ( <DiaryItem key={item.id} {...item} /> ))} </div> </div> ); }; export default DiaryList; //DiaryItem.jsx import { getEmotionImage } from "../util/get-emotion-image"; import Button from "./button"; import "./DiaryItem.css"; const DiaryItem = (id, emotionId, createdDate, content) => { return ( <div className="DiaryItem"> <div className={`img_section img_section_${emotionId}`}> <img src={getEmotionImage(1)} /> </div> <div className="info_seciton"> <div className="created_date"> {new Date(createdDate).toLocaleDateString()} </div> <div className="content">{content}</div> </div> <div className="button_section"> <Button text={"수정하기"} /> </div> </div> ); }; export default DiaryItem;
-
해결됨한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
Context 질문입니다.
첫번째 context Provider 에 {data} 두번째 context Provider 에 {onCreate,onUpdate,onDelete}이렇게 2개를 사용해야 하는건가요? 1개로 value 에{data, onCreate,onUpdate, onDelete} 이렇게는 안되는건가요? 안되는 거라면 이유가 있을 런지요?복잡한 상태 관리가 필요한 경우에 종류별로 많이 사용된다면 코드가 복잡해질거 같은데요 ㅠ 그리고 실무에서 상태관리를 위해서 Redux를 많이 사용하는 거 같더라구요? 현재 react 강좌에는 Redux 내용은 없는거 같아요 ㅠㅠ 추가 보충설명 공유주시면 감사할거 같아요 ~~
-
해결됨웹 프론트엔드를 위한 자바스크립트 첫걸음
왜 전부다 div태그로 만드는지 궁금합니다.
강사님 강의를 들으면서 의문이 들었는데 강사님 버튼 부분으로 되어있는 것들을 div태그로 전부다 만드시던데 혹시 이유가 따로 있을까요???북마크를 추가하는 부분이나 취소, 추가 부분은 button태그를 사용하거나 북마크를 입력하는 div태그 전체를 form태그로 묶어서 사용하는게 좀 더 좋지 않을까요??강사님이 div 태그만 사용하시던데 혹시 이유가 따로 있으신건가요??
-
해결됨웹 프론트엔드를 위한 자바스크립트 첫걸음
[수업질문] bookmark.js에서
6, 북마크 아이템 추가하기에서 추가 버튼을 누르면 bookmarkList.push is not a function at HTMLDivElement.addBookMarkItem 이라고 콘솔에 나옵니다 ..ㅠㅠ(css와 마크업은 미리 적어두었습니다.)