[나작프] 000_count

김현주·2022년 2월 22일
0

나의작은프로젝트

목록 보기
2/9

000_count

// ( src/App.js )
import React, { useState } from 'react';
import './App.css';

function App() {
  const [counter, setCounter] = React.useState(0);
  
  const upCount = () => { setCounter(counter+1) };
  const downCount = () => { setCounter(counter-1) };
  
  return (
    <div className="container">
      <h1>Count: { counter }</h1>
      <div className="btn-container">
        <button onClick={ upCount }>Up</button>
        <button onClick={ downCount }>Down</button>
      </div>
    </div>
  );
}

export default App;

🤔 리액트에서 제일 기본적인 useState를 다시 돌아보았다.

profile
✨프론트엔드 개발자가 되기 위한 독학러✨

0개의 댓글