[esercizio] React Hooks 1


React Hooksの練習


1. useState


import React, {useState} from "react";

const app = () => {
  const [item, setItem] = useState(1);
  // useState(기본값/삽입값), item은 state값, setItem은 setState랑 동일
  const increment = () => setItem(item + 1)
  const decrement = () => setItem(item - 1)

  return (
  <div className="App">
      <h1>{item}</h1>
      <button onClick ={increment}>Increment</button>
      <button onClick ={decrement}>Decrement</button>
    </div>
  )
}

export default App

1.useState成果物