본문 바로가기

전체 글90

[Hooks] 1. 사용법 배우기 노마드코더 www.youtube.com/playlist?list=PL7jH19IHhOLOagok7uFWKlOleLF64grb6 리액트 훅은 리액트의 신박한 기능인데, state, component에 대한 것들을 많이 바꿔놓는다. 결론적으로 말하자면 functional component에서 state를 가질 수 있게 해준다. 앱을 리액트 훅으로 만든다면 class component, did mount, render 이런 것들을 안해도 된다. 모든것은 하나의 function이 되는것이다. (함수형 프로그래밍) 아주 많은 사람들이 그들의 Hooks를 공유한다. hooks의 구조와 쉽게 hooks를 만들 수 있는 사실 자체가 사람들이 자신의 hooks를 공유하도록 권장하고 격려한다고 생각한다. 간단한 카운트를 .. 2020. 8. 14.
[Vanilla-JS] 3. Canvas Events canvas는 div라고 생각하자. canvas가 없을수도 있으니까 canvas가 존재하는지 확인할거다. (mousemove로 존재확인) const canvas = document.getElementById("jsCanvas"); function onMouseMove(event) { console.log(event); } if (canvas) { canvas.addEventListener("mousemove", onMouseMove); } clientX, Y는 이 윈도우 전체의 범위 내에서 마우스 위치값을 나타내는건데, 우리는 캔버스내에서의 좌표만 있으면 된다. (캔버스를 screen 사이즈로 했으면 당연히 client와 값이 같을거다.) 우리는 캔버스 크기를 다르게 했으니 다른 X&Y 값을 가진다. 캔.. 2020. 8. 13.
[알고리즘] 2. 가장 낮은 절댓값 찾기 https://www.codingame.com/ide/puzzle/temperatures import sys import math # Auto-generated code below aims at helping you parse # the standard input according to the problem statement. n = int(input()) # the number of temperatures to analyse if n == 0: print("0") else: result = 5527 temperatures = input().split(' ') for i in range(n): t = int(temperatures[i]) if t == 0: result = t break elif abs(.. 2020. 8. 12.
[알고리즘] 1. 반복문으로 가장 높은 산을 파괴(최댓값) https://www.codingame.com/ide/puzzle/the-descent import sys import math while True: max_h = 0 index = 0 for i in range(8): mountain_h = int(input()) if mountain_h > max_h: max_h = mountain_h index = i print(index) ★ 최댓값과 인덱스 변수를 루프 밖에 선언하면 계속 같은 인덱스만 출력한다. 그러므로 변수선언시 유심히 생각해본다. 2020. 8. 12.