React
Components

Components

A React component is an individual file written in JSX. A component can be a functional component or a stateful component. Functional components contain no logic and are purely for the purpose of design. Stateful components contain logic that can update the DOM, make API calls, etc.

demo.js
import styles from "../../components/counters.module.css";
 
export const Counter = () => {
  const [count, setCount] = useState(0);
  return (
    <div>
      <button onClick={() => setCount(count + 1)} className={styles.counter}>
        Clicked {count} times
      </button>
    </div>
  );
};
 
// in page use component
<Counter />;

Component