React
-
nomard) Clean Up 함수React 2023. 3. 16. 16:45
Clean UP. : useEffect( 함수 , [] ) 를 사용할 때 변하는 값을 지정하지 않으면 해당 함수는 생성될 때 한번 작동하고 끝이다. 다음과 같은 함수를 해당 컴포넌트가 없어질 때 특정 함수가 작동하게 만드는 것이 Clean Up 함수이다. function something() { useEffect( () => { console.log("Hi"); return () => console.log("bye"); }, []); }; -> something 함수가 다른곳에서 불리면 console.log("Hi")를 실행하고, something 함수가 제거되면 console.log("bye")를 실행한다.
-
nomard) React 설치 및 연결React 2023. 3. 16. 12:49
리액트 설치 방법 : ReactJS 어플리케이션 개발에 도움을 준다. 1. nodejs 설치 - nodejs 홈페이지에서 설치 후 cmd로 version과 npx를 확인해주면 node를 사용할 수 있는지 확인할 수 있다. **** node를 설치하는 도중 vs code가 켜져있었다면 꼭 재부팅 해주자, 그렇지 않으면 vs code가 node를 인식할 수 없다 2. node.js 를 이용해 react 다운로드 : react는 대표적으로 node.js 와 yarn을 통해 다운로드 가능하다 - node.js 는 가급적 c 드라이브에 설치하자 - cmd에서 node -v , npm -v 명령어로 버전을 확인하는 것으로 설치가 잘 됬는지 확인할 수 있다. cmd 창에서 react를 전역으로 설치하자 (로컬로 설치..
-
nomard) ReactJS 기본, useState, Component, propsReact 2023. 3. 13. 11:23
setCounter((current) -> current +1) => current와 함수를 이용해서 현재 값을 보장받는다 https://nomadcoders.co/react-for-beginners ReactJS로 영화 웹 서비스 만들기 – 노마드 코더 Nomad Coders React for Beginners nomadcoders.co 1 _ 리액트란? : react js는 웹 사이트에 interactivity ( 상호작용 )을 만들어준다. 일반적인 바닐라 js를 이용할 경우 간단한 기능일지라도 작성하기 번거로운 경우가 많이 발생한다. react는 자주 사용되는 기능을 쉽게 가져올 수 있게 만든 기능이다. 리액트를 사용하기 위해 import 해보자 - react와 react dom reactdom 의..