묻고 답해요
158만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결공공데이터로 파이썬 데이터 분석 시작하기
14. distplot g = sns.FacetGrid(df_last, row="지역명", height=1.7, aspect=4) g.map(sns.distplot, "평당분양가격", hist=False, rug=True); 오류
결과 값이 나오긴 하는데 그 위에 붉은색으로 오류.. 인건지 뭔가가 나옵니다.. 내용은 다음과 같은데요 /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seaborn/axisgrid.py:854: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `kdeplot` (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 func(*plot_args, **plot_kwargs) 강좌 내용과 같게 결과는 나오는데 위처럼 나오는 이유를 모르겠습니다...
-
미해결비개발자를 위한 RPA 강의 (UiPath 기본편)
Microsoft OCR 확인 불가
Microsoft OCR 이 액티비티에서 확인이 되지 않습니다.윈도우 10에서 기본 제공한다고 말씀 하셨는데 저는 현재 윈도우 11을 사용해서 차이가 발생하는 것 같습니다.이런 경우에 대체할 수 있는 방법이 있을까요?
-
미해결스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
검증1부분에 html이 이상하게 조회됩니다.
화면에서 아래와 같이 이렇게 뜹니다. 뭐가 문제인지 알려줄 수 있나요? html은 건드른게 없어요.
-
미해결[입문자를 위한 UE5] Part4. 언리얼 엔진 C++
선생님 강의 늘 잘보고 있습니다 문제가 좀 있는데요
C++클래스를 생성할 때 하위폴더를 만들어 생성하면 그 위치의 헤더파일을 인식을 하질 못합니다 분명 경로에 있고 VS상에도 필터구조 아래에 잘 들어가 있는데 인식을 못하는 문제가 있는데 VS를 지웠다 깔아도 마찬가지입니다 이런 경우 해결방법이 있을까요?-> 선생님 이문제는 강의 듣다보니 바로 나왔네요 해당 하위폴더를 지우고 막바로 헤더를 인클루드 하니 해결되었습니다 -> 인클루드 하니 비주얼스튜디오 상에선 해결이 되었는데 언리얼 에디터 상에서 폴더구조가 반영이 안됩니다 혹시 이경우는 어떻게 하면 좋을까요? 또 저같은 경우 라이브코딩이 켜져있으면 빌드할 때 에러가 납니다 선생님은 같은 증상이 없으신지요?
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
테스트코드 작성시
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? 예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예[질문 내용]테스트 코드 작성시 Test Results라고만 나오고 하위에 save() 이렇게 나오지 않습니다. 왜 그런걸까요??
-
미해결게임 프로그래머 취업 전략 가이드
알고리즘 공부는 어느정도 하면 될까요?
물론 많이하면 할수록 좋겠지만 당장 빠르게 취직을 원한다 하면 백준에서 골드4~2 정도의 문제를 풀수 있을정도면 될까요?얼마전 포트폴리오 작업을 끝내고 알고리즘 공부를 시작했는데 어느정도 하고 이력서를 제출해야할지 고민입니다
-
미해결스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
@ModelAttribute @RequestParam
안녕하세요. 강의를 듣던중 궁금한 내용이 생겼는데 구글링을 해도 명확한 답변이 나오지않아 질문드립니다ㅠㅠ 강의 내용중 컨트롤러의 파라미터에서, @ModelAttribute MultipartFile file와 @RequestParam MultipartFile file의 차이가 무엇인지 질문드립니다..!강의 자료에서는 ' @ModelAttribute에서도 MultipartFile을 동일하게 사용할수있다 ' 고 되어있지만, 어차피 file.getOriginalFilename()을 사용하는것은 @ModelAttribute나 @RequestParam이나 동일한것같은데, 어떨때 @ModelAttribute를 사용해야하고, 어떨때 @RequestParam을 사용해야하는지 모르겠습니다.. 둘중 아무거나 사용해도 되는건가요..? 바로 뒤 강의에서는 @ModelAttribute로서 MultipartFile을 받아오는거같은데 어떨때 사용하는것인지 궁금해서 질문드립니다..! 감사합니다!
-
미해결김영한의 실전 자바 - 중급 1편
Long 참조변수 더하기 연산
public class WrapperVsPrimitive { public static void main(String[] args) { // wrapper class Long sumWrapper = 0L; /// Long = long (auto boxing) for (int i=0; i<iterations; i++) { sumWrapper += i; /// Long += long (auto boxing) } } }위 코드에서 'sumWrapper += i;' 부분이 이해가 되지 않는데요. 이전에 말씀해주셨듯이 참조형변수는 주소값을 가지고 있기에 참조변수를 통한 값 계산이 불가합니다. 그래서 참조변수 간 더하기 연산이 불가합니다.그런데, 이 코드는 long 타입인 i -> Long으로 auto boxing된 이후에 (Long 타입 참조변수) + (Long 타입 참조변수)인 것인데, String 타입 참조변수와 마찬가지로 자바에서 wrapper class 타입 참조변수 간 더하기 연산을 제공하는 것인가요?그렇다면 Long 타입 참조변수 간 더하기 연산이 일어나게 되면, Long 인스턴스가 내부적으로 가진 long에 더하기 연산이 적용되는 걸까요??
-
미해결김영한의 실전 자바 - 중급 1편
5. enum 열거형 문제와 풀이2 관련 질문
[질문 내용]문제와 풀이 해설이랑 조금 달라서 질문 남겨봅니다. 저는 이런식으로 작성하였는데 문제없이 잘 돌아가긴 했는데요 혹시 이렇게 작성하면 보이지 않는 다른 오류가 발생하는지 궁금합니다. 또, isSuccess() 메서드에서 findByCode()메서드를 호출하였는데 이런 방식을 실무에서도 많이 쓰는 편인가요??
-
미해결[C++과 언리얼로 만드는 MMORPG 게임 개발 시리즈] Part5: UE5 & IOCP 서버 연동
파트4의 서버 파일이랑 다른건가요??
파트4에서 서버 프레임워크 강의를 보고 파트5로 넘어왔습니다.그런데 중간중간 서버 프레임워크 소스가 다른곳이 있는거 같은데요, 예를 들어 서버에서 사용중인 패킷핸들러 cpp에서 인클루드되어있는 파일이 현재 파트5 강의에서는 BufferReader.h와 BufferWrite.h를 포함하고있습니다. 파트4 기준으로 해당 헤더는 포함되어있지 않구요. 그리고 패킷 핸들러.h 에서는 현재 파트5에서는 MakeShared하는 부분을 언리얼과 구분 지어서 MakeShared, make_share로 강의를 해주셨는데, 애초에 파트4의 핸들러에서는 make_shared를 사용하지 않고SendBufferPtr sendBuffer = GSendBufferManager->Open( packetSize );소스를 이용중인것으로 보이는데요..혹시 제가 중간에 잘못본 강의가 있는걸까요?
-
미해결10주완성 C++ 코딩테스트 | 알고리즘 코딩테스트
히든퀘스트2-3 질문이 있습니다.
https://blog.naver.com/aratino5165/223431323815설명 다적혀있는 구현문제라 쉬울줄 알았는데 테스트 케이스가 맞는게 거의 없습니다.문자열을 L, R로 쪼개고 L을 규칙에 맞게 수정R로 위에것 반복으로 이해했는데 큰돌님 코드를 보니 string c부터 이해가 안됩니다.
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
강의 너무 잘 듣고 있습니다 혹시 part2는 언제쯤 나올까요?
언제쯤 나올까요 ㅠㅠ 강사님 너무 잘가르치십니다
-
미해결AWS Certified Solutions Architect - Associate 자격증 준비하기
실전 문풀 13회 29번 질문있습니다.
읽기 전용 복제본은 트래픽을 분산시키는 용도로 알고 있는데, 이 경우 고가용성은 어떻게 보장해줄 수 있나요?? Redis용 캐시가 고가용성을 보장하면서 캐시를 통해 (반복된) 읽기를 줄일 수 있다고 보는데 잘 이해가 안가서 질문드립니다.
-
미해결[게임 프로그래머 입문 올인원] C++ & 자료구조/알고리즘 & STL & 게임 수학 & Windows API & 게임 서버
C2666 ERRROR 관련 문의 드립니다 (operator == 오버로드~) - [17주차] 온라인 게임 개론
안녕하세요 선생님, 강의 열심히 듣고 있습니다.17주차 온라인 게임 개론에서 수업자료 받아서 실행시켜 보았는데, 아래와 같은 에러가 발생합니다ㅠㅠ 처음에 CollisionManager와 UI included 되어 있어서 컴파일 에러나는 거 때문에 그 부분만 include 된거 삭제하였고 다른거는 하나도 건들지 않았는데도 저런 에러가 뜨네요.. 각 오류에 해당하는 line의 코드는 아래와 같습니다. 구글에 찾아봐도 해결 방법을 모르겠네요.. 도움 주시면 감사 드리겠습니다!
-
해결됨장고 설계철학으로 시작하는 파이썬 장고 입문
개발환경 구축 관련하여 질문드립니다.
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 안녕하세요. 기존에 python을 웹에서 설치를 진행 했었습니다.get-commad python 명령어를 실행할 경우 기존에 사용하던 version과 설치 돼 있는 경로가 제가 예전에 만들었던 가상환경에 python.exe.로 표시 돼 있는데 scoop으로 도 python설치를 진행 했을 경우 get-commad python 명령어를 입력했을 때 scoop/apps 안에 있는 파이썬 버젼을 가져오는 방법이 있을까요?
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
7강 application.yml에 문제가 있는거 같습니다...
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오) 예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 아니오 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) 예[질문 내용]현재 구글링 하면서도 진행 해봤지만 다른게 문제인지 h2 console에도 insert 구문이 날라가지 않습니다 ...현재 제가 놓친게 있을까요 ?... 지금 스프링부트 버전은 3.2.5 버전입니다. 자바 버전도 17로 설정되어 있습니다.해당 프로젝트 주소 : https://drive.google.com/file/d/1SbgjH5aDY_j_g07r9_Kmz4Uk-uImcC9L/view?usp=drive_link
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
7강 application.yml에서 막히고 있습니다...
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오) 예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 아니오 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]현재 7강에서 h2에 insert가 안되가지고 구글링 다 하면서 여러 방법을 시도해보았지만 해결이 안되서 강의 진행을 못하고 있습니다. .. 현재 제가 놓친 부분이 있다면 가르쳐주시면 감사하겠습니다.그리고 testMember에 커밋은 구글링 하다가 마지막 방법으로 찾아본거라 이전 방법은 다 해본 것 같습니다.
-
해결됨[임베디드 입문용] 임베디드 개발은 실제로 이렇게 해요.
보드 전원 3.3V 문의 드립니다.
네이버에서 보드만 구매 했습니다.USB 전원만 인가하면 LED D1은 계속 ON.D2는 깜밖임 상태입니다. 이 상태에서 STM32F103C8T6 "VBAT" 1번 핀의 전원이 2V가 인가 됩니다.그 외 J2 1~3핀을 이용하여 측정해도 2V가 나옵니다.왜 3.3V가 안되는지 궁금 합니다
-
미해결[리뉴얼] React로 NodeBird SNS 만들기
redux toolkit, saga으로 하는중에 devtool에서 액션 명칭이 undefined로 나옵니다
안녕하세요 제로초님여쭤보고 싶은게 있습니다.강의를 따라가다가 데브툴에서 액션, 데이터들을 확인하시는 모습을 봤는데,저도 따라해보니 액션명칭도, state tree의 데이터들도 제대로 안나오는것 같더라구요.그래서 좀 테스트해보니까아래의 로직처럼put에 액션 함수를 실행하면 데브툴에서 액션 명칭니 나오고예시: put(액션명(데이터)),기존처럼put({type: 액션명, payload: 데이터}) 호출하게되면undefined로 나오는것 같습니다.function* addPost(action) { try { yield delay(1000); const id = shortid.generate(); yield put(addPostSuccessAction({ id, content: action.payload.text, }) ); yield put({ type: addPostToMe, payload: id }); } catch (err) { yield put({ type: addPostFailureAction, error: err.response.data }); } }아무래도 toolkit과 saga를 사용할때 저렇게 사용하는게 아닌가 싶은데undefined로 나오는 부분은 개선했다고 하더라도action 부분이 제로초님과 다르게 나오더라구요.액션명만 나오는게 아니라 reducer의 위치도 함께나온느데이렇게 나와도 괜찮은건지 여쭙고 싶습니다.다른 부분은 잘 작동하는것 같습니다. import { HYDRATE } from "next-redux-wrapper"; import { createSlice } from "@reduxjs/toolkit"; import shortId from "shortid"; export const initialState = { mainPosts: [ { id: "1", User: { id: "1", nickname: "zzimzzim", }, content: "첫 번째 게시글 #해시태그, #익스프레스", Images: [ { id: shortId.generate(), src: "https://loremflickr.com/cache/resized/65535_53669042936_630c778818_320_240_nofilter.jpg", }, { id: shortId.generate(), src: "https://loremflickr.com/cache/resized/65535_52982053835_12fc661207_320_240_nofilter.jpg", }, { id: shortId.generate(), src: "https://loremflickr.com/cache/resized/65535_52905479084_303bf25ec0_320_240_nofilter.jpg", }, ], Comments: [ { id: shortId.generate(), User: { nickname: "찜찜", }, content: "얼른 사고싶어요~", }, { id: shortId.generate(), User: { nickname: "hero", }, content: "리액트 넥스트 고수가 될테다~", }, ], createdAt: {}, }, ], imagePaths: [], addPostLoading: false, addPostDone: false, addPostError: null, addCommentLoading: false, addCommentDone: false, addCommentError: null, }; const dummyPost = ({ id, content }) => { return { id, content, User: { id: "1", nickname: "WlaWla", }, Images: [], Comments: [], }; }; const dummyComment = (content) => ({ id: shortId.generate(), content: content, User: { id: "1", nickname: "WlaWla", }, }); const postSlice = createSlice({ name: "post", initialState, reducers: { addPostRequestAction: (state, action) => { state.addPostLoading = true; state.addPostDone = false; state.addPostError = null; }, addPostSuccessAction: (state, action) => { state.addPostLoading = false; state.addPostDone = true; state.mainPosts.unshift(dummyPost(action.payload)); }, addPostFailureAction: (state, action) => { state.addPostLoading = false; state.addPostError = action.error; }, addCommentRequestAction: (state, action) => { state.addCommentLoading = true; state.addCommentDone = false; state.addCommentError = null; }, addCommentSuccessAction: (state, action) => { const { content, userId, postId } = action.payload; const post = state.mainPosts.find((d) => d.id === postId); post.Comments.unshift(dummyComment(content)); state.addCommentLoading = false; state.addCommentDone = true; }, addCommentFailureAction: (state, action) => { state.addCommentLoading = false; state.addCommentError = action.error; }, }, extraReducers: (builder) => builder .addCase(HYDRATE, (state, action) => ({ ...state, ...action.payload.post, })) .addDefaultCase((state) => state), }); export const { addPostRequestAction, addPostSuccessAction, addPostFailureAction, addCommentRequestAction, addCommentSuccessAction, addCommentFailureAction } = postSlice.actions; export default postSlice.reducer; 사가 코드입니다.import { all, fork, delay, put, takeLatest } from "redux-saga/effects"; import axios from "axios"; import { addPostRequestAction, addPostSuccessAction, addPostFailureAction, addCommentRequestAction, addCommentSuccessAction, addCommentFailureAction } from "../reducers/post"; import { addPostToMe, removePostOfMe } from "../reducers/user"; import shortid from "shortid"; function addPostAPI(data) { return axios.post("/api/post/", data); } function* addPost(action) { try { // const result = yield call(addPostAPI, action.data); console.log("addPost saga", action); yield delay(1000); const id = shortid.generate(); yield put( addPostSuccessAction({ id, content: action.payload.text, }) ); yield put({ type: addPostToMe, payload: id }); } catch (err) { yield put({ type: addPostFailureAction, error: err.response.data }); } } function addCommentApi(data) { return axios.post(`/api/post/${data.postId}/comment`); } function* addComment(action) { try { // const result = yield call(addPostAPI, action.data); console.log("addComment saga", action); yield delay(1000); yield put({ type: addCommentSuccessAction, payload: action.payload, }); } catch (err) { console.log(err); yield put({ type: addCommentFailureAction, error: err.response.data, }); } } function* watchAddPost() { yield takeLatest(addPostRequestAction, addPost); } function* watchAddComment() { yield takeLatest(addCommentRequestAction, addComment); } export default function* postSaga() { yield all([fork(watchAddPost), fork(watchAddComment)]); }
-
해결됨Next + React Query로 SNS 서비스 만들기
특정인 정보 api 질문
안녕하세요 제로초님,특정인 정보 api(api/users/{id}) response 관련 질문이 있습니다.response에 Followers 배열이 있어해당 유저를 팔로우 한 다른 사용자들을 얻고자 했습니다. 처음 시도는 강의에서 진행했던대로prefetchQuery + useQuery 조합으로 데이터를 끌어오고자 했습니다.하지만 이 경우에 Followers 배열이 빠진 상태로 응답이 돌아오고 있습니다.한 100번 새로고침하면 1~2번만 붙어서 옵니다.아래는 prefetchQuery + useQuery 조합 코드입니다. // page.tsx import Link from "next/link"; import { QueryClient, HydrationBoundary, dehydrate } from "@tanstack/react-query"; import getUserInfo from "./_lib/getUserInfo"; import getUserPosts from "./_lib/getUserPosts"; import Nav from "./_component/Nav"; import ProfileUserData from "./_component/ProfileUserData"; import UserPosts from "./_component/UserPosts"; import { Container, Userzone, Profile, HeaderPhotoZone } from "./page-style"; type Props = { params: { username: string }; }; export default async function Username({ params }: Props) { const { username } = params; console.log("username : ", username); const queryClient = new QueryClient(); await queryClient.prefetchQuery({ queryKey: ["user", username], queryFn: getUserInfo, }); await queryClient.prefetchQuery({ queryKey: ["posts", "user", username], queryFn: getUserPosts, }); return ( <Container> <HydrationBoundary state={dehydrate(queryClient)}> <Nav username={username} /> <Userzone> <Profile> <HeaderPhotoZone> <Link href="/home">{/* <Image src={이미지} alt="header_photo"></Image> */}</Link> </HeaderPhotoZone> <ProfileUserData username={username} /> </Profile> <UserPosts username={username} /> </Userzone> </HydrationBoundary> </Container> ); } //Nav.tsx "use client"; import { useQuery, useQueryClient } from "@tanstack/react-query"; import getUserInfo from "../_lib/getUserInfo"; import BackBtn from "../../_component/BackBtn"; import { Navigation } from "./style"; import { User } from "@/model/User"; type Prop = { username: string; }; export default function Nav({ username }: Prop) { const { data } = useQuery<User, Object, User, [_1: string, _2: string]>({ queryKey: ["user", username], queryFn: getUserInfo }); console.log("네비게이션 유저 데이터 : ", data); return ( <Navigation> <BackBtn></BackBtn> {data === undefined ? ( <div>프로필</div> ) : ( <div> <div>{data?.nickname}</div> <div>0 게시물</div> </div> )} </Navigation> ); } //ProfileUserData.tsx "use client"; import { useQuery, useQueryClient } from "@tanstack/react-query"; import Link from "next/link"; import { useSession } from "next-auth/react"; import Tab from "./Tab"; import FollowButton from "../../_component/FollowButton"; import { ProfileUserdataMid, UserName, SignupDate, AboutFollower, ProfileUserdata, NoAccountId, NoAccountMsg, ProfileUserdataTop, AbsoluteProfileContainer } from "./style"; import { User } from "@/model/User"; import getUserInfo from "../_lib/getUserInfo"; type Prop = { username: string; }; export default function ProfileUserData({ username }: Prop) { const { data: session } = useSession(); const { data } = useQuery<User, Object, User, [_1: string, _2: string]>({ queryKey: ["user", username], queryFn: getUserInfo }); console.log("프로필 유저 데이터 : ", data); // const createdDate = new Date(data?.createdAt!); if (data === undefined) { return ( <> <NoAccountId>@{username}</NoAccountId> <NoAccountMsg>계정이 존재하지 않음</NoAccountMsg> </> ); } // return null; // 팔로우, 팔로잉 데이터 추가 필요 return ( <ProfileUserdata> <ProfileUserdataTop> <AbsoluteProfileContainer> <div>아 몰랑</div> </AbsoluteProfileContainer> {/* 팔로우 버튼 확인 */} {/* <Link href="/settings/profile">프로필 수정</Link> */} {/* {session?.user?.email === data?.id ? <Link href="/settings/profile">프로필 수정</Link> : <FollowButton user={data} />} */} </ProfileUserdataTop> <ProfileUserdataMid> <UserName> <div>{data?.nickname}</div> <div>@{data?.id}</div> </UserName> <SignupDate> <svg viewBox="0 0 24 24" aria-hidden="true" height="1.25rem"> <g> <path d="M7 4V3h2v1h6V3h2v1h1.5C19.89 4 21 5.12 21 6.5v12c0 1.38-1.11 2.5-2.5 2.5h-13C4.12 21 3 19.88 3 18.5v-12C3 5.12 4.12 4 5.5 4H7zm0 2H5.5c-.27 0-.5.22-.5.5v12c0 .28.23.5.5.5h13c.28 0 .5-.22.5-.5v-12c0-.28-.22-.5-.5-.5H17v1h-2V6H9v1H7V6zm0 6h2v-2H7v2zm0 4h2v-2H7v2zm4-4h2v-2h-2v2zm0 4h2v-2h-2v2zm4-4h2v-2h-2v2z"></path> </g> </svg> {/* <div>{`가입일 ${createdDate.getFullYear()}년 ${createdDate.getMonth() + 1}월`}</div> */} </SignupDate> <AboutFollower> <Link href="/follow"> <span>{data._count.Followings}</span> 팔로우 중 </Link> <Link href="/followers"> <span>{data._count.Followers}</span> 팔로워 </Link> </AboutFollower> <Tab></Tab> </ProfileUserdataMid> </ProfileUserdata> ); } react-query 결과 때문에 다른 방법으로 prefetchQuery를 사용하지 않고useQuery만을 사용해서 특정인 정보를 가져오는 시도를 했는데이 경우에는 모두 Followers 배열이 같이 날아오더군요.왜 이런 현상이 일어나는지 궁금해 질문 남깁니다.아래는 useQuery만 사용한 코드는 page.tsx에 prefetchQuery만 빠진 것 이외에 다른 부분은 동일합니다.//page.tsx import Link from "next/link"; import { QueryClient, HydrationBoundary, dehydrate } from "@tanstack/react-query"; import getUserInfo from "./_lib/getUserInfo"; import getUserPosts from "./_lib/getUserPosts"; import Nav from "./_component/Nav"; import ProfileUserData from "./_component/ProfileUserData"; import UserPosts from "./_component/UserPosts"; import { Container, Userzone, Profile, HeaderPhotoZone } from "./page-style"; type Props = { params: { username: string }; }; export default async function Username({ params }: Props) { const { username } = params; console.log("username : ", username); const queryClient = new QueryClient(); // await queryClient.prefetchQuery({ // queryKey: ["user", username], // queryFn: getUserInfo, // }); await queryClient.prefetchQuery({ queryKey: ["posts", "user", username], queryFn: getUserPosts, }); // 개인 사용자 데이터 가져오는 것으로 수정해ㅑ함 // 이거 서버 컴포넌트인데 Nav 같은거는 client란 말이야 그래서 깜박거리는데 어카지; return ( <Container> <HydrationBoundary state={dehydrate(queryClient)}> <Nav username={username} /> <Userzone> <Profile> <HeaderPhotoZone> <Link href="/home">{/* <Image src={이미지} alt="header_photo"></Image> */}</Link> </HeaderPhotoZone> <ProfileUserData username={username} /> </Profile> <UserPosts username={username} /> </Userzone> </HydrationBoundary> </Container> ); } react - query 결과useQuery만 사용했을 때의 네트워크 탭getUserInfo.tsx는 다음과 같습니다.import { QueryFunction } from "@tanstack/query-core"; import { User } from "@/model/User"; const getUserInfo: QueryFunction<User, [_1: string, _2: string]> = async ({ queryKey }) => { const [_1, username] = queryKey; const response = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/api/users/${username}`, { credentials: "include", }); if (response.ok) return response.json(); }; export default getUserInfo;