Props vs State in React: What's the Difference?

Learn how props pass data into React components, how state stores changing data, and how callback props let children request updates.

Props vs State in React: What's the Difference?

Props vs. State in React

React components need information to render. Some information comes from a parent component; other information changes while the component is being used. React handles these with props and state.

  • Props are values a component receives from its parent. They configure what the child displays or how it behaves.
  • State is changing data held by a component (or by an ancestor that shares it). Updating state tells React that the UI may need to render again.

An easy starting point is: props come in; state is managed by the component that owns it. Props are read-only from the receiving component's side. If a child interaction should change data owned by a parent, the parent can pass a callback prop for the child to call. React: Passing Props to a Component · React: State: A Component's Memory

Props configure a component

When a parent renders a child, it can pass values through JSX attributes:

function Greeting({ name }) {
  return <h2>Hello, {name}!</h2>;
}

function App() {
  return <Greeting name="Mina" />;
}

App passes "Mina" as the name prop. Greeting receives that value and uses it to render. The child should not assign a different value to its prop. If the parent later renders <Greeting name="Rafi" />, the child receives the new prop on that render.

Props can hold strings, numbers, objects, arrays, functions, and JSX. A callback passed as a prop is still a prop; it gives a child a way to ask the parent to do something.

State changes over time

Use state for information that can change as someone interacts with a component. In a function component, useState provides the current state value and a setter:

import { useState } from "react";

function NameInput() {
  const [name, setName] = useState("");

  return (
    <label>
      Your name
      <input value={name} onChange={(event) => setName(event.target.value)} />
      <p>Hello, {name || "there"}!</p>
    </label>
  );
}

The name value is local state owned by NameInput. When the input changes, setName gives React the next value. React schedules a render so the paragraph can show the updated name. Do not mutate a state variable directly; use its setter. React may skip rendering children if the next state is identical to the current value, so think of a setter as requesting a state update rather than a guarantee that every call produces a visible render. React: useState

A child can request a parent's state update

Suppose a parent owns a counter but a child button displays and increments it. Pass the current count and an event handler down as props:

import { useState } from "react";

function CounterButton({ count, onIncrement }) {
  return <button onClick={onIncrement}>Count: {count}</button>;
}

export default function CounterApp() {
  const [count, setCount] = useState(0);

  function increment() {
    setCount((currentCount) => currentCount + 1);
  }

  return <CounterButton count={count} onIncrement={increment} />;
}

CounterApp owns the state. CounterButton receives count and onIncrement as props. When clicked, it calls the callback; the parent updates its own state, then React passes the new count back down. The child does not mutate the parent's props or state.

When multiple components need to coordinate the same changing value, move that state to their closest common parent and pass values and callbacks down. This pattern is called lifting state up. React: Sharing State Between Components

Props vs. state at a glance

PropsState
Where does the value come from?A parent passes it to the componentThe component that owns it initializes and updates it
Can the receiving component change it directly?No; it asks the parent to pass a new propIt requests a change using a state setter
Typical purposeConfigure a child or pass data/callbacksRemember changing data between renders
Examplename, onSave, isOpen passed to a childname typed into an input, isOpen toggled locally

The same kind of information can be a prop in one component and state in another. For example, a parent may keep isOpen in state and pass it as an isOpen prop to a dialog.

Common mistakes

  • Trying to change a prop in the child. Ask the parent to provide a callback if the child needs to request a change.
  • Changing state directly. Call the setter returned by useState; for objects and arrays, create updated values instead of mutating existing ones.
  • Duplicating the same state in multiple components. Keep one source of truth and pass the value to components that need it.
  • Putting every value in state. Values that can be calculated from existing props or state often do not need their own state variable.

Try it yourself

Create a Profile parent with state for a user's name. Pass the name and an onNameChange callback to a NameEditor child. The child should display an input and call the callback when it changes. Which component owns the state? Which values are props?

Recap

  • Props pass data and callbacks from parent to child; the receiving child treats them as read-only.
  • State stores changing data for the component that owns it.
  • Use a state setter to update state and let React update the UI.
  • A child can request an update by calling a callback prop; shared state often belongs in the closest common parent.

What's next?

Next, we’ll learn why a React component re-renders and what can trigger a render.

Written by

Dev Likhon

Dev Likhon

Full Stack Developer & Tech Educator

6+ years of professional development experience.

About Me
Share:

Comments

Share what you learned or ask a question.

Loading comments...