useState

유관희·2022년 5월 29일
0
post-thumbnail
post-custom-banner

Import useState

import { useState } from "react";

Initialize useState

import { useState } from "react";

function FavoriteColor() {
  const [color, setColor] = useState("");
}

Example:

import { useState } from "react";
import ReactDOM from "react-dom/client";

function FavoriteColor() {
  const [color, setColor] = useState("red");

  return <h1>My favorite color is {color}!</h1>
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<FavoriteColor />);
profile
안녕하세요~
post-custom-banner

0개의 댓글