Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react button onclick components refined #1

function Button(){
  const [counter , setCounter] = useState(1);
  const handleClick = () => setCounter(counter*3);
  return ( 
    <button onClick={handleClick}>
    {counter}
  </button>)
}
ReactDOM.render(
<Button />,
document.getElementById('mountNode'),
  );
Source by jscomplete.com #
 
PREVIOUS NEXT
Tagged: #react #button #onclick #components #refined
ADD COMMENT
Topic
Name
8+2 =