React Coding Challenges Flashcards

1
Q

React Code for making a counter

A
import React, { useState } from 'react';

function Example() {
  const [count, setCount] = useState(0);

  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>
        Click me
      </button>
    </div>
  );
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly