In React, props vs state?
Options
- They are the same thing under two different names
- Props are inputs from the parent; state is internal (Correct option)
- State comes only from the server, never from users
- Props can only be strings, never objects or numbers
Answer
Props are inputs passed from the parent (read-only for the child); state is data the component owns and can change, triggering a re-render
Why
Props are like function arguments: the parent passes them, the child reads them but must not change them.
State is the component's own memory (useState). When you update it with the setter, React re-renders the component with the new value.
If the child needs to change something, the parent passes a function as a prop (e.g. onChange).
Remember
Props = given by the parent. State = owned and changeable.