본문 바로가기

REACT

노마드코더 useState 예제

import React, { Component, useState } from "react";
import "./styles.css";

const App = () => {
  const [count, setCount] = useState(0);
  const [email, setEmail] = useState("");
  const updateEmail = e => {  
  const {
      target:{value}
    } = e;
    setEmail(value);
  };
  return (
    <>
      {count}
      <button onClick={() => setCount(count + 1)}>Increment </button>
      <button onClick={() => setCount(count - 1)}>Decrement </button>
      <input placeholder="Email" value ={email} />
    </>
  );
};

export default App;