Skip to content
doubtly

1 answer

Props are read-only inputs passed from a parent component to a child; state is data that a component owns and can change, and changing state makes React re-render the component.

Props (properties)

  • Passed like HTML attributes: <Greeting name="Riya" />.
  • Immutable inside the child (the child must not modify them).
  • Allow one component to be reused with different data.
function Greeting(props) {
  return <h2>Hello, {props.name}!</h2>;
}

function App() {
  return (
    <div>
      <Greeting name="Riya" />
      <Greeting name="Aman" />
    </div>
  );
}

State

  • Private data managed inside the component (with useState in function components, or this.state/this.setState in class components).
  • Updated only through the setter function, never by direct assignment.
  • Each update triggers a re-render with the new value.
import { useState } from "react";

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

Using both together: a parent can keep state and pass it down as props, e.g. <Display value={count} />. Data flows one way, from parent to child.

PropsState
Passed from parentCreated inside the component
Read-onlyChangeable via setter
Used to configure a componentUsed for data that changes over time (input text, counters, fetched data)
Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.