분류 전체보기
-
[프로그래머스 level.1] 06.19알고리즘 2023. 6. 19. 11:50
최소직사각형 더보기 https://school.programmers.co.kr/learn/courses/30/lessons/86491?language=javascript 내가 쓴 코드 function solution(sizes) { let width = []; let height = []; for(let i = 0; i < sizes.length; i++) { const max = Math.max(sizes[i][0], sizes[i][1]); const min = Math.min(sizes[i][0], sizes[i][1]); width.push(max); height.push(min) } const answer = Math.max(...width) * Math.max(...height) return ..
-
[리액트를 다루는 기술] 컴포넌트의 반복프로그래밍/React 2023. 6. 18. 18:14
반복되는 컴포넌트를 다루는 기술~ 박복되는 코드를 작성하는 경우 (댓글달기 같은 경우를 생각하면 됨) key라는 놈이 좀 중요한 역할을 한다 이 key를 설정을 안해주면 Virtual DOM을 일일히 비교하면서 변화를 감지하는 수고스러운 행동을 하기 때문에 key를 설정하고 이 key의 변화를 바로바로 얘기해주면 아주 좋다 props 설정 하는 것처럼 하면 되서 하기도 쉽다 쉬워~ 이때 map()함수 꿀팁이 있으니 map()함수에서 보자 map() 먼저 ES6문법에서 새로워진 화살표함수와 const를 통해서 정의하는게 보기 좋다 key 설정 꿀팁은 map함수에서 전달되는 콜백함수의 index값을 이용하자 이다. map()을 써서 일일히 key를 할당을 해야하는데 이 방식을 쓴다면 아주 꿀빨면서 key를 ..
-
[리액트를 다루는 기술] 이벤트카테고리 없음 2023. 6. 18. 16:43
이벤트 이벤트란 사용자가 웹브라우저에서 DOM요소들과 상호작용 하는 것을 말한다. 리액트의 이벤트는 HTML에서의 이벤트와 유사하기에 걱정 없이 사용가능이다. 주의사항 카멜표기법을 사용해야함 "-" 이런거 쓰지마셈 이벤트에 할당되는 값은 함수로 주어져야한다 (JS코드 XX) DOM요소에만 적용가능하지 괜히 이런데에 하지 말자.. 이벤트 함수 여러개 있던데 그건 나중에 정리 한번 해볼까?? 비동기적으로 객체를 참조하는 것 이게 뭐냐함은 SyntheticEvent는 네이티브 이벤트와 달리 이벤트가 끝나면 이벤트가 초기화 되서 정보를 참조 할 수 없다 그래서 비동기적으로 이벤트 객체를 참조하는 방법은 e.persist()를 호출하는것 ex) e.target.value .... 컴포넌트에 여러개의 인풋이 있고 ..