0
0
Reactframework~5 mins

State vs props comparison in React - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What is state in React?
State is a way to store data inside a component that can change over time. It controls the component's behavior and appearance. When state changes, the component updates its output.
Click to reveal answer
beginner
What are props in React?
Props are inputs passed from a parent component to a child component. They are read-only and cannot be changed by the child component.
Click to reveal answer
beginner
Can a component change its own props?
No, a component cannot change its own props. Props are controlled by the parent component and are read-only inside the child.
Click to reveal answer
intermediate
When should you use state instead of props?
Use state when you need to keep track of data that changes inside the component, like user input or toggles. Use props to pass fixed or external data from parent to child.
Click to reveal answer
beginner
How does changing state affect a React component?
Changing state causes the component to re-render, updating what the user sees. This makes the UI dynamic and interactive.
Click to reveal answer
Which of the following can a React component modify directly?
ANeither state nor props
BProps
CState
DBoth state and props
Props in React are:
AImmutable data passed from parent to child
BMutable data owned by the component
CUsed to store local component data
DChanged by the child component
What happens when a component's state changes?
AThe component unmounts
BThe component re-renders
CProps are updated
DNothing changes visually
Which is true about props?
AThey are used to pass data down from parent to child
BThey can be changed by the component receiving them
CThey store temporary data inside a component
DThey cause the component to re-render when changed internally
When should you use state in a React component?
ATo hold data passed from a parent
BTo pass data to child components
CTo make props read-only
DTo store data that changes over time inside the component
Explain the difference between state and props in React.
Think about who controls the data and if it can change inside the component.
You got /4 concepts.
    Describe a real-life example where you would use state and another where you would use props in a React app.
    Imagine a form input for state and a label showing a name for props.
    You got /4 concepts.