Props and State

Props

Props (short for properties) are read-only attributes passed from parent to child components.

function Welcome(props) {
  return <h1>Hello, {props.name}!</h1>;
}

State

State is used for dynamic and interactive components.

import { useState } from 'react';
function Counter() {
  const [count, setCount] = useState(0);
  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => setCount(count + 1)}>Increase</button>
    </div>
  );
}
export default Counter;