노마드코더 강의로 ReactJS 스터디를 시작하였습니다! 새로운 언어를 배우는 만큼 큰 설렘을 가지고 한 번 열심히 수강해보도록 하겠습니다! 화이탱..구리구리
ReactJS makes the UI more interactive --> makes interactivity in the website very simple
Building vanillaJS to compare it with ReactJS
Vanilla JS using only html - making the button
<!DOCTYPE html>
<html>
<body>
<button id="btn">Click me</button>
</body>
<script>
const button = document.getElementById("btn");
function handleClick(){
console.log("I have been clicked");
}
button.addEventListener("click",handleClick);
</script>
</html>
Vanilla JS only using html - displaying clicks
<!DOCTYPE html>
<html>
<body>
<button id="btn">Click me</button>
</body>
<!--step #1 create html, step #2 grab it from javascript, step #3 listen for events, step #4 update the data, step #5 update the html as well-->
<span>Total clicks: 0</span>
<script>
let counter = 0;
const span = document.querySelector("span");
const button = document.getElementById("btn");
function handleClick(){
counter = counter +1;
span.innerText=`Total clicks: ${counter}`;
}
button.addEventListener("click",handleClick);
</script>
</html>
importing react and react-dom into html
<!DOCTYPE html>
<html>
<body>
</body>
<script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script>
<script>
</script>
</html>