따라하며 배우는 노드, 리액트 시리즈 - 레딧 사이트 만들기(NextJS)(Pages Router)
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 94강 13:55초를 보면 콘솔 창에 next-dev.js?3515:20 Invalid href passed to next/router: /u//r/ test02/043hzrH/test44 , repeated forward-slashes (//) or backslashes \ are not valid in the hre 와 같은 에러가 떠있습니다. [username].tsx에서 <Link href={`/u/${comment.post?.url}`}> 을 불러 올때 url에 '/r/test02/043hzrH/test44'가 담겨 오면서 슬래쉬(//)가 2번 입력되어 생기는 에러 같습니다. 제공된 소스코드에도 위와 같이 입력되어 있어요. 아래와 같이 '/'를 지우고 링크를 href에 넣어주면 에러가 사라지는데 이게 맞을까요? <Link href={`/u${comment.post?.url}`}>
따라하며 배우는 노드, 리액트 시리즈 - 레딧 사이트 만들기(NextJS)(Pages Router)
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 백엔드 entities에서 Post, Sub, Comment는 아래와 같이 import Post from "../entities/Post" import Sub from "../entities/Sub" import Comment from "../entities/Comment" 처럼 불러올 수 있게 작성하셨는데 User만 import {User} from "../entities/User" 중괄호를 넣어서 불러와야 합니다. export default class User extends BaseEntity 가 아닌 export class User extends BaseEntity 로 작성한 이유가 있을까요?
따라하며 배우는 노드, 리액트 시리즈 - 레딧 사이트 만들기(NextJS)(Pages Router)
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 81강을 수강중입니다. src/pages/r/[slug]/[identifier]/[slug].tsx 작성중 {post.voteScore} 를 콘솔로 찍어보면 undefined가 나와서 페이지에 노출되지 않습니다. 타입을 voteScore? : number 로 한게 문제인가해서 ?를 지워보았지만, 증상은 동일했고 api를 불러오면서 voteScore는 0으로 초기화되지 않은채 받는것 같아요. 그러던 중 백엔드의 Post.ts를 살펴보았더니 get voteScore()를 get V oteScore()로 오타 아닌 오타를 가져가서 초기화 되지 않았단걸 알아내었습니다. 누군가에게 도움이 되시길 바라며
cats.service.ts 파일 import { Injectable } from '@nestjs/common'; @Injectable() export class CatsService { getAllCats(): string { return 'get all cats1'; } } export const getAllCatsTest = () => { return 'get all cats2'; }; cats.controller.ts 파일 import { CatsService } from './cats.service'; import * as catsService2 from './cats.service'; import { Controller, Get, } from '@nestjs/common'; @Controller('cats') export class CatsController { constructor(private catsService: CatsService) {} @Get() getAllCat() { return this.catsService.getAllCats(); } @Get('2') getAllCat2() { return catsService2.getAllCatsTest(); } } Dependency Injection을 사용해야하는 이유가 명확히 이해가 안됩니다. A라는 클래스에서 B라는 클래스를 인스턴스화 (new 키워드 사용) 했을 때, A클래스가 B클래스에 대해서 의존성이 발생하고 만약에 B 클래스의 수정점이 발생한다면, A클래스도 수정해줘야하는 부분은 인지를 했습니다. 그런 경우에 변화를 유연하게 대응하기 위해 A클래스에서 직접 인스턴스화를 하는것이 아니라, 인스턴스화된 클래스를 주입받아 사용만 하는걸 Dependency Injection(의존성 주입)으로 이해했습니다. 하지만, import해서 쓰면 되는걸 왜 굳이 의존성주입이라는 형태로 사용해야하는지 이해를 못했습니다. 제가 위에 예시로 작성한 service 파일과 controller를 보시면, getAllCat()는 의존성 주입해서 사용한거고, getAllCat2는 import한 서비스를 사용한겁니다. 어떠한 이유에서 의존성 주입의 개념을 사용해야하는지 명쾌하게 알고 싶습니다.
강의를 잘 따라 가면서 공부를 하고 있는데 강좌에 나와있는대로 class-validator 을 npm -i class-validator 을 설치 후 nest를 실행하니 nest 에서 Cannot find module 'class-validator/types/decorator/decorators' 라는 에러를 나타냅니다. 혹시 몰라서 API 공식문서 에 있는 npm i class-validator class-transformer 을 다시 설치를 해보아도 같은 에러를 나타내는데 이럴 경우 어디서 확인을 해보아야 할까요? 혹시 몰라서 package.json 을 살펴 보았습니다만 dependencies 내에 설치가 되어있는것으로 나왔습니다.
Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. PS C:\Users\PC\Desktop\emotion diary> npm install -g serve changed 89 packages, and audited 90 packages in 10s 23 packages are looking for funding run npm fund for details PS C:\Users\PC\Desktop\emotion diary> cd hello PS C:\Users\PC\Desktop\emotion diary\hello> serve -g build serve : 이 시스템에서 스크립트를 실행할 수 없으므로 C:\Users\PC\AppData\Roaming\npm\ser ve.ps1 파일을 로드할 수 없습니다. 자세한 내용은 about_Execution_Policies( https://go.mic rosoft.com/fwlink/?LinkID=135170)를 참조하십시오. 위치 줄:1 문자:1 + serve -g build + ~~~~~ + CategoryInfo : 보안 오류: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess PS C:\Users\PC\Desktop\emotion diary\hello> npm run build > hello@0.1.0 build > react-scripts build Creating an optimized production build... Compiled with warnings. [eslint] src\components\DiaryItem.js Line 32:16: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text src\components\DiaryList.js Line 1:15: 'useEffect' is defined but never used no-unused-vars src\components\EmotionItem.js Line 6:13: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text src\pages\Diary.js Line 20:7: React Hook useEffect has a missing dependency: 'id'. Either include it or remove the dependency array react-hooks/exhaustive-deps Line 37:7: React Hook useEffect has a missing dependency: 'navigate'. Either include it or remove the dependency array react-hooks/exhaustive-deps Line 58:25: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text src\pages\Edit.js Line 5:9: 'getStringDate' is defined but never used no-unused-vars Line 22:7: React Hook useEffect has a missing dependency: 'id'. Either include it or remove the dependency array react-hooks/exhaustive-deps Line 39:7: React Hook useEffect has a missing dependency: 'navigate'. Either include it or remove the dependency array react-hooks/exhaustive-deps Search for the keywords to learn more about each warning. To ignore, add // eslint-disable-next-line to the line before. File sizes after gzip: 54.79 kB build\static\js\main.544a876e.js 1.42 kB build\static\css\main.b7fc6af2.css The project was built assuming it is hosted at /. The build folder is ready to be deployed. You may serve it with a static server: serve -s build Find out more about deployment here: https://cra.link/deployment PS C:\Users\PC\Desktop\emotion diary\hello> serve -s build serve : 이 시스템에서 스크립트를 실행할 수 없으므로 C:\Users\PC\AppData\Roaming\npm\ser ve.ps1 파일을 로드할 수 없습니다. 자세한 내용은 about_Execution_Policies( https://go.mic rosoft.com/fwlink/?LinkID=135170)를 참조하십시오. 위치 줄:1 문자:1 + serve -s build + ~~~~~ + CategoryInfo : 보안 오류: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess PS C:\Users\PC\Desktop\emotion diary\hello> npm install -g serve와 npm run build를 했습니다 you may serve it with a static server라는 메시지와함께 serve -s build라는 메세지도 떴는데 serve -s build라고 명령어를 입력했는데도 입력이 되지 않습니다... 루트폴더 문제인가요? 문제가 무엇인가요
안녕하세요. 웹 프로젝트를 진행하면서 궁금한 점이 있어서 질문드립니다. mysql과 sequelize를 사용하며 users 테이블과 contents 테이블이 1:N 관계를 가지고 있습니다. 그래서 users 데이터를 delete 할 때 자식으로 묶인 contents 데이터들을 cascade 옵션을 통해 같이 delete 시키고자 합니다. models/contents.js models/users.js 이때 그냥 삭제시키는 게 아니라 users 테이블과 contents 테이블 모두 paranoid 옵션을 통해 deletedAt을 생성시키고 삭제된 날짜를 찍히게 하고자 하는데 현재 user를 delete 하면 user는 삭제가 되어 deletedAt이 잘 나오지만 content는 삭제가 되지 않아 deletedAt이 나오지 않는 상황입니다. 구글링을 통해 여러 방법을 시도해 보았지만 해결되지 않아 질문드립니다. hooks나 api를 사용하지 않고 cascade를 통해 자식 요소까지 삭제되면서 deletedAt이 잘 나올 수 있는 효과적인 방법이 있을까요?
안녕하세요. classname 작성하실때 어떤건 className = {name} 이런식으로 괄호 안에 넣고 어떤건 단순히 className = "name" 이렇게 하시는데 혹시 어떤 차이가 있고 이유는 무엇인지 궁금합니다 ㅠㅠ 이미 가르쳐주셨던건데 제가 모르는거 같기도 하네요
20강에서 Router 예제 복붙 시 오류안나는 최종본입니다 !! import React from "react"; import { Route, Routes, BrowserRouter } from "react-router-dom"; import LandingPage from "./components/views/LandingPage/LandingPage"; import LoginPage from "./components/views/LoginPage/LoginPage"; import RegisterPage from "./components/views/RegisterPage/RegisterPage"; function App() { return ( <BrowserRouter> <div> {/* A <Switch> looks through its children <Route>s and renders the first one that matches the current URL. */} <Routes> <Route exact path="/" element={LandingPage()}/> <Route exact path="/login" element={LoginPage()}/> <Route exact path="/register" element={RegisterPage()}/> </Routes> </div> </BrowserRouter> ); } export default App;
자바스크립트 함수 인강에서 return문 개념이 너무 헷갈려서요. function getArea(width*height){ let area = width* height; return area; } let area1 = getArea(100,200); return을 쓰면 위와 같이 항상 새로운 변수를 지정해서 getArea함수를 호출해야하나요? 왜 return을 사용하는지 잘 모르겠어요..
안녕하세요~ 강의 듣던 중 궁금증이 생겨 질문 남깁니다 useReducer로 CREATE 상태 로직을 분리할 때, 기존과 다르게 newItem을 reducer에서 생성하는 이유가 무엇인가요? 아래처럼 기존과 동일한 방식으로 newItem을 onCreate 내에서 생성했을 경우에도 정상 동작하는 것 같은데 혹시 동작이나 성능면에서 차이점이 있나요? +) 계속 생각할수록 로직을 분리할 때 어디서부터 어디까지 분리해야할지 기준을 잘 모르겠어요,,ㅠ 강의에서 CREATE로직 분리 시 newItem을 reducer에서 생성한 것 처럼, INIT로직 분리 시에도 initData를 reducer에서 생성 할 수 있을 것 같은데(아래 코드).. 분리하는 로직의 기준점? 같은걸 어떻게 잡아야할지 잘 모르겠습니다ㅜㅜ 혹시 어떤 기준으로 분리해야할지 규칙이나 팁같은게 있을까요?
안녕하세요 강사님! 최적화3 - useCallback 강의 듣던 중 의문점이 생겨 질문 남깁니다. onCreate에 useCallback을 사용하고 의존성 배열을 빈 값으로 두면 mount시에 한번만 실행되기 때문에 data state가 초기값인 빈 배열인 상태이다 <= 까지는 이해하였습니다. 그런데 함수형 업데이트를 이용해서 인자로 data를 전달하면 최신 data state를 반영할 수 있다는 부분이 잘 이해가 안갑니다. onCreate가 mount시에 생성되고 생성시의 data state가 계속 유지된다면 인자로 전달되는 data state또한 초기값인 빈 배열이 들어가게되어 결국 setData(([]) => [ newItem, [] ]) 처럼 동작해야 하는것이 아닌가요? 어떻게 인자로 전달되는 data에는 최신 상태가 반영되는건가요??
TypeError: user.comparePassword is not a function >>비주얼에서는 이런식으로 자꾸 오류가 뜨고, 포스트맨에서는 Could not get response Error: read ECONNRESET 이렇게 뜹니다,,!!! post는 http://localhost:5000/api/users/login 이던 http://localhost:5000/login이던 다 안돼요,,, 답변 부탁드립니다ㅠㅠㅠㅠㅠㅠ