Answers for "use useState in react component"

9

usestate react hook

import React, { useState } from 'react';

function Example() {
  // Declare a new state variable, which we'll call "count"  
  const [count, setCount] = useState(0);
  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>
        Click me
      </button>
    </div>
  );
}
Posted by: Guest on September-08-2020
1

usestate in react

const [x, setx] = useState(0);
Posted by: Guest on July-13-2021

Code answers related to "use useState in react component"

Browse Popular Code Answers by Language