Answers for "eact functional compoentns update state on click"

0

eact functional compoentns update state on click

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-21-2020

Code answers related to "eact functional compoentns update state on click"

Code answers related to "Javascript"

Browse Popular Code Answers by Language