React Hooks useState() Code

Here is the code for the video https://youtu.be/7KAb_XpWzWI
 
 
 
'use client';

import { useState } from "react";
import "./style.css";

const Home = () => {
  const [count, setCount] = useState(0);
  const [myColor, setMyColor] = useState("blue-color");

  const increment = () =>{
    setCount(count + 1);
  }

  const changeColor = () =>{
    setMyColor("red-color");
  }

  return (
    <>
      <h1 className={myColor}>useState Hook</h1>
      <h1>{count}</h1>
      <button onClick={increment}>Increment</button>
      <button onClick={changeColor}>RED</button>
    </>
  );
};

export default Home;


 

No comments:

Post a Comment

DELETE A RECORD FROM MYSQL DATABASE USING VANILLA JAASCRIPT WITH API CODED IN PHP

 Code as used in the video: delete.js export const deleteModal = async ( studId , refreshDisplay ) => {   document . getElementById...