묻고 답해요
164만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨웹 게임을 만들며 배우는 React
setTries를 하면 Cannot read properties of undefined (reading 'length') 에러가 뜹니다.
안녕하세요 제로초님. 항상 좋은 강의 감사드립니다. 유튜브로 강의 듣다가 3-8강에서 질문을 하기 위해 인프런 수강신청하여 질문 남깁니다. (유튜브는 질문댓글이 삭제되더라구요) 코드를 아래와 같이 작성하였는데, 리액트가 tries.length를 인식하지 못하는 현상이 발생합니다. tries 자체는 useState로 초기화해주었는데 tries.length의 length를 인식하지 못하는 이유가 무엇인가요? 문제 원인을 찾기 위해 setTries를 onChangeInput에 넣었을 때, 타이핑하자마자 바로 에러가 뜨는 걸로 봐선 tries를 setState할 때 에러가 발생하는 것 같은데 명확한 에러원인을 잘 모르겠습니다. 코드는 아래와 같습니다. https://github.com/kth990303/TH-s-Web/issues/1 https://github.com/kth990303/TH-s-Web/tree/master/react-webgame/baseball import React,{useState} from 'react'; import Try from './Try' const getNumbers=()=>{ const candidate=[1,2,3,4,5,6,7,8,9], ans=[]; for(let i=0;i<4;i++){ const chosen=candidate.splice(Math.floor(Math.random()*(9-i)), 1)[0]; ans.push(chosen); } return ans; } const NumberBaseball=()=>{ const [result, setResult]=useState(''); const [value, setValue]=useState(''); const [answer, setAnswer]=useState(getNumbers()); const [tries, setTries]=useState([]); const onSubmitForm=(e)=>{ e.preventDefault(); if(value===answer.join('')){ setResult('홈런!'); setTries((prevTries)=>{ [...prevTries, {try:value, result:'홈런!'}] }) } else{ const answerArray=value.split('').map((v)=>parseInt(v)); let strike=0, ball=0; if(tries.length>=9){ setResult(`10번 넘게 틀려서 실패! 답은 ${answer.join(',')}였습니다!`); alert('게임을 다시 시작합니다.'); setValue(''); setAnswer(getNumbers()); setTries([]); } else{ for(let i=0;i<4;i++){ if(answerArray[i]===answer[i]){ strike++; } else if(answer.includes(answerArray[i])){ ball++; } } setTries((prevTries)=>{ [...prevTries, {try: value, result:`${strike}스트라이크 ${ball}볼입니다.`}] }) setValue(''); } } } const onChangeInput=(e)=>{ console.log(tries.length); setValue(e.target.value); } return( <> <h1>{result}</h1> <form onSubmit={onSubmitForm}> <input maxLength={4} value={value} onChange={onChangeInput} /> <button>입력!</button> </form> <div>시도: {tries.length}</div> <ul> {tries.map((v,i)=>{ return( <Try key={`${i+1}차 시도: ${v.try}`} tryInfo={v} /> ); })} </ul> </> ) } export default NumberBaseball; 감사합니다!
-
미해결우리를 위한 프로그래밍 : 파이썬 중급 (Inflearn Original)
iterator, generator 질문
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 안녕하세요. 10:44에서 wt=iter(wg) 하고 print(wt)를 하면 generator라고 나오는데 interator 가 아니고 generator인 이유가 무엇인가요? 가령 t = 'asdfgh' w= iter(t) print(w)하면 str_iterator 라고 나오는데 차이가 궁금합니다.
-
미해결설계독학맛비's 실전 FPGA를 이용한 HW 가속기 설계 (LED 제어부터 Fully Connected Layer 가속기 설계까지)
create block design error
[BD 41-1348] Reset pin /led_0/rst (associated clock /led_0/clk) is connected to asynchronous reset source /processing_system7_0/FCLK_RESET0_N. This may prevent design from meeting timing. Please add Processor System Reset module to create a reset that is synchronous to the associated clock source /processing_system7_0/FCLK_CLK0. 이라고 나오는데 왜 이런건가요?
-
미해결시스템엔지니어가 알려주는 리눅스 실전편 Bash Shell Script
mariabackup 오류 관련
안녕하세요 저와 동일한 오류가 발생하신 분이 있길래 답변주신걸로 해봤는데 해결이 안되네요.. (참고답변 https://www.inflearn.com/questions/179156) 다음과 같은 오류가 뜹니다. 쉘 스트립트에서 해도 동일한 오류가 발생합니다....
-
미해결HTML+CSS+JS 포트폴리오 실전 퍼블리싱(시즌1)
비주얼 코딩 프로그램에서 이미지 저장 경로 설정(맥)
맥에서 이미지를 경로 복사하여 붙여 넣기를 하는데 웹에서 이미지가 안뜹니다 어떻게 하는 걸까요?
-
해결됨[리뉴얼] React로 NodeBird SNS 만들기
질문드립니다 getServerSideProps or getInitialProps
만약 모든 페이지에서 사용자 정보가 SSR되어야한다면 getServerSideProps보다 getInitalProps로 _app에다가 설정하는게 나을꺼 같은데 혹시 이 방법 말고 더 좋은 방법이 있을까 여쭤봅니다. getInitalProps는 레거시 코드니까 사용하지 않는 게 좋다는데 이거 말고 대안을 못 찾겠네요.ㅠㅠ 1. _app -> getInitalProps MyApp.getInitialProps = wrapper.getInitialAppProps( (store) => async ({ Component, ctx }) => { store.dispatch( setCredentials({ user: await axios .get("http://localhost:4000/users/me", { withCredentials: true, headers: { cookie: ctx.req?.headers.cookie || "", }, }) .then((response) => response.data) .catch(() => null), }) ); return { pageProps: { ...(Component.getInitialProps ? await Component.getInitialProps({ ...ctx, store }) : {}), pathname: ctx.pathname, }, }; } ); 2. pages -> getServerSideProps wrapper.getServerSideProps((store) => async (context) => { store.dispatch( setCredentials({ user: await axios .get("http://localhost:4000/users/me", { withCredentials: true, headers: { cookie: context.req.headers.cookie || "", }, }) .then((response) => response.data) .catch(() => null), }) ); return {props: {}}; });
-
미해결스프링 시큐리티
강사님 강의자료 인용에 대해
개인적으로 공부를 정리하는 블로그가 있는데요 강의 ppt 사진같은 부분을 인용하여 작성하여도 괜찮으실까요 ??
-
미해결스프링 시큐리티
어떠한 차이가 있는지 궁금합니다.
defaultSuccessUrl syccessHandler failureUrl failureHandler 각각에 메소드가 둘중하나만 써도 될거같은데 두개 다 쓰신 이유를 모르겠습니다!!..
-
미해결스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술
파일명과 클래스명 일치 에러
회원 관리 웹 애플리케이션 요구사항 강의에서 패키지명을 member로 하셧고 메소드 클래스 이름도 member로 하셨는데 왜 일치 하지 않는다 떠서 이런 오류가 나는지 모르겠습니다 ..
-
미해결풀스택을 위한 탄탄한 프런트엔드 부트캠프 (HTML, CSS, 바닐라 자바스크립트 + ES6) [풀스택 Part2]
웹페이지연습강의 들으면서
궁금한게 생겨 질문드립니다 ...! 강의 중 말씀하셨을지도 모르지만 기억이 잘 안나기도 하고 궁금해서요 .. !! index.html을 작성할때 크게 header section footer 이런식으로 나누는건 그게 웹페이지의 직접적인 영향을 끼치는게 아니라 부분부분 나눠서 효율적으로 작성하기 위함인것으로 압니다 .. !! 각각 작성할때 그 안에 div를 작성하고 inner라는 클래스를 항상 생성해주시는데 그거는 웹페이지를 작성할 때 부분부분을 나눌때 하는 특정 방식인건가요 ?? 질문이 너무 애매한데 ... 예를 들어 footer를 작성하고 그 자체를 inner라고 가정하고 작성하면안되는지 궁금합니다 ..! footer 안에 div.inner를 만들고 또 그안에 div.footer-message를 만들면 너무 중첩하는건 아닌가 궁금하기도 해서요 .. !!
-
미해결[리뉴얼] React로 NodeBird SNS 만들기
제가 백엔드 sql port 번호설정을 잘못한거 같습니다..
영상을 보면 브라우저 3060 프론트 서버(Next) (3060) 백엔드 서버(express) (3065) MySQL(3306)라고 되어있는데 저는 제꺼는 프론트 서버는 3060이고 백엔드 서버는3000이고 MySQL 3306으로 들어가면 아래오류가 뜨고 3000번으로 들어가면 로그인이 됩니다. 어디서부터 잘못된 느낌이 들어서 질문올립니다.... 프론트 서버이고 백엔드 서버입니다. 그리고 백엔드 서버에서 port를 3000으로 맞춰줘야 db연결 성공이 떠서 3000으로 맞췄습니다..
-
미해결Vue.js 시작하기 - Age of Vue.js
vue cli 설치 오류
- (base) mac@Macui-MacBookPro learn-vue-js-master % npm install -g @vue/cli npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated npm WARN deprecated apollo-tracing@0.15.0: The `apollo-tracing` package is no longer part of Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#tracing for details npm WARN deprecated graphql-extensions@0.15.0: The `graphql-extensions` API has been removed from Apollo Server 3. Use the plugin API instead: https://www.apollographql.com/docs/apollo-server/integrations/plugins/ npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address' npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated apollo-cache-control@0.14.0: The functionality provided by the `apollo-cache-control` package is built in to `apollo-server-core` starting with Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#cachecontrol for details. npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi' npm WARN deprecated graphql-tools@4.0.8: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as @graphql-tools/schema, @graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead changed 944 packages, and audited 945 packages in 24s 65 packages are looking for funding run `npm fund` for details 23 vulnerabilities (4 moderate, 19 high) To address issues that do not require attention, run: npm audit fix Some issues need review, and may require choosing a different dependency. Run `npm audit` for details. npm 최신 안정버전설치, 전부 삭제 후 그냥 최신 버전 설치 다 해봤는데 cli 설치가 안되네요. npm audit fix하면 (base) mac@Macui-MacBookPro learn-vue-js-master % npm audit fix npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen) npm WARN deprecated vue-cli@2.9.6: This package has been deprecated in favour of @vue/cli added 245 packages, and audited 246 packages in 2s 7 packages are looking for funding run `npm fund` for details # npm audit report ansi-regex >2.1.1 <5.0.1 Severity: moderate Inefficient Regular Expression Complexity in chalk/ansi-regex - https://github.com/advisories/GHSA-93q8-gq69-wqmw fix available via `npm audit fix` node_modules/inquirer/node_modules/ansi-regex node_modules/string-width/node_modules/ansi-regex strip-ansi 4.0.0 - 5.2.0 Depends on vulnerable versions of ansi-regex node_modules/inquirer/node_modules/strip-ansi node_modules/string-width/node_modules/strip-ansi inquirer 3.2.0 - 7.0.4 Depends on vulnerable versions of string-width Depends on vulnerable versions of strip-ansi node_modules/inquirer vue-cli >=2.9.0 Depends on vulnerable versions of inquirer node_modules/vue-cli string-width 2.1.0 - 4.1.0 Depends on vulnerable versions of strip-ansi node_modules/string-width 5 moderate severity vulnerabilities To address all issues, run: npm audit fix 이렇게 나와서 npm audit fix 하면 또 위에 상황 반복이구요... 전에 vue 잘 설치해서 공부하다가 잠깐 쉬고 지금 다시 설치하는건데 계속 안되서 진행을 못하고 있습니다....ㅠ
-
미해결리눅스 시스템 프로그래밍 - 이론과 실습
return 과 exit 차이를 알고 싶습니다.
안녕하세요 프로그램에서 return 0 , return -1 해도 되고, exit 0, exit -1 이런식으로도 사용하는데 ... 둘의 차이를 알고 싶습니다.
-
미해결[리뉴얼] React로 NodeBird SNS 만들기
cors 질문입니다.
cors 는 브라우저에서 다른 서버로 도메인이 다른곳으로 url에 요청을 보낼떄 나타나고 , 프론트서버에서 백엔드서버로 요청보낼땐 상관없다고하셧는데, 저희의 방식은 요청을 saga에서받아서 (프론트서버), 요청을 하는것이아닌가요 ? 그럼 서버에서 서버라 cors 문제가 없어야 정상아닌지요 ? 궁금해서 여쭤봅니다.
-
미해결윤재성의 Oracle SQL Database 11g PL/SQL Developer
안녕하세요 수업 너무 유익하게 듣고있는 학생입니다.
강사님 수업 유익하고 잘 보고 있는데 혹시 블로그에 출처 남기고 배운 내용을 포스팅해도 될까요?
-
미해결딥러닝 CNN 완벽 가이드 - TFKeras 버전
모델 불러와서 evaluate하기
안녕하세요 선생님 모델을 학습 후 model.save를 이용하여 mh5형식으로 저장을 하여 추 후에 활용 하려고 할때 model.save를 이용하여 모델을 저장 후에 학습한 모델을 load_model 함수를 이용하여 불러와서 활용하려고 할 때 저장된 모델을 불러와 evaluate 또는 prediction 함수를 활용 하면 어떤 가중치가 적용되는지 궁금합니다. 예를들어 1. model.compile에 있는 loss 기준으로 가장 낮은 에폭의 가중치를 가져오는지? 2. earlystop를 활용 했을때는 EarlyStopping의 monitor에 들어간 밸류를 기준으로 가장 좋은 가중치를 불러오는지 답변 부탁드립니다. 감사합니다.
-
미해결Flutter 입문 - 안드로이드, iOS 개발을 한 번에 (with Firebase)
accentColor deprecated
main.dart 에서 themdata를 강의와 동일하게 적었는데 accentColor 속성이 deprecated됐다고 colorschem?으로 migration하라고 합니다. 코드를 어떻게 변경해야 할까요? 안드로이드스튜디오의 가이드대로 hemeData( appBarTheme: AppBarTheme( backgroundColor: Colors.white ), colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.blue).copyWith(secondary: Colors.black),), 이렇게 적었는데 exit_to_app 버튼이 검은색으로 보이지 않고 흰색으로 보입니다. 버전이 달라서 그런거같은데, Icon에서 color: Colors.black으로 직접 주니까 검은색으로 변경되긴 했습니다. main.dart에서 적용하려면 어떻게 써야할지 궁금합니다~
-
미해결파이썬 알고리즘 문제풀이 입문(코딩테스트 대비)
아나그램 문제 질문 드립니다.
선생님, 항상 강의 잘 듣고 있습니다. 아나그램 문제를 이렇게 짰는데 채점기도 다 통과했거든요. 코드 이렇게 짜도 되나요??
-
미해결[파이토치] 실전 인공지능으로 이어지는 딥러닝 - 기초부터 논문 구현까지
데이터 증강 관련 질문 드립니다.
안녕하세요 딥러닝호형님! 좋은 강의 정말 잘 보고 있습니다. 데이터 증강에 대해 궁금한 점이 있습니다. 데이터 증강을 적용할 경우 각 배치마다 개별 이미지 샘플이 여러개의 변형된 샘플로 증강되는 것인가요? 아니면 각 배치마다 개별 이미지 샘플이 랜덤하게 한장의 이미지로 변형되어, 결과적으로 배치마다 다르게 변형된 이미지 구성으로 학습하게 되는 것인가요? 그럼 답변 기다리겠습니다. 감사합니다!
-
미해결타입스크립트 시작하기
2: 38
enum 타입으로 정의된 Fruit 은 객체로 존재한다고 하셨는데, 어째서 5번째 "인덱스" 를 알수 있다고 하신건가요? 자바스크립트에서는 배열에서 인덱스를 알려면 당연히 '[ ]' 기호를 사용해서 인덱스에 접근할수 있고, 자바스크립트에서의 객체의 인덱스를 알려면 함수의 인수에 '...' 를 사용해서 객체를 받아오고, 해당 객체를 함수 내부에서 콘솔로그로 출력해보면 배열안에 해당 객체가 들어있는 것을 알수 있기 때문에 "인덱스" 라는 것에 접근할수 있는 것으로 알고 있습니다. const obj = { name: 'james', age: 20 } function f1(...arg){ console.log(arg); // [ { name: 'james', age: 20 } ] console.log(arg[0]); // { name: 'james', age: 20 } } f1(obj) 그런데 enum 타입으로 정의된 변수 Fruit 은 어떻게 해서 "인덱스" 로 접근이 가능하게 되는 것인가요? 말씀하신 코드를 (Fruit[5] ) 출력해보지 않고 보기만 하면 Fruit 은 배열인것인거고, 5번째 요소가 존재하는걸로 이해하게 되어서 Fruit 는 배열인것이고, Fruit 라는 배열안에 요소가 5개가 들어가있는 것으로 이해가 되서요.... 현재 enum 타입으로 정의된 Fruit 내부의 요소는 총 3개인데... 제가 잘못 이해하고 있는 걸까요?