
웹 게임을 만들며 배우는 React - 인프런
useState는 값이 변하면 재렌더됨useRef는 값이 변하지만 렌더될 필요가 없을 때 사용.current로 값 접근해야함
timeout 눌러서 시작 후 눌러야 하는 화면 나오게 하는 setTimeout 담는 refstartTIme 눌러서 시작 한 시각을 저장하는 refendTIme 눌러서 종료한 시각을 저장하는 ref map 으로 하는게 나음가위바위보 게임
componentDidMount() 컴포넌트가 첫 렌더링 된 후setIntervalcomponentDidUpdate() 리렌더링 후componentDidUpdate() 컴포넌트가 제거되기 직전render() 안에서 setState하면 무한하게 렌더componentDidMoint에 작성componentWIllUnmount에서 제거

(사실 이부분은 무슨내용인지 잘 모르겠다)
onclick={()=> this.onclickBtn('바위')} ()=> 를 빼서 함수에 2번째 인자로 넣는다onClickBtn = (choice) => {...} -> onClickBtn = (choice) => () => {...}componentDidMountcomponentDidUpdatecomponentWillUnmount 시기에 실행로또추첨기
componentDidUpdate setState될때 실행됨componentDidUpdate(prevProps, prevState){
if(this.state.winBalls.length === 0){
this.runTimeouts();
}
}
useEffect(()=>{
...
},[]); //빈 배열이면 componentDidMount와 동일
//배열에 요소가 있으면 componentDidMount랑 componentDidUpdate 둘 다 수행
