A. Props are being mutated directly, which is not allowed.
B. The component should use this.state instead of props.
C. The return statement is missing parentheses.
D. The component should not return JSX.
Solution
Step 1: Check for props mutation
The line props.count = props.count + 1; tries to change props directly, which is not allowed.
Step 2: Understand correct data handling
Props are read-only; to change data, use state or callbacks, not direct mutation.
Final Answer:
Props are being mutated directly, which is not allowed. -> Option A
Quick Check:
Direct props mutation = error = A [OK]
Hint: Never assign to props; use state for changes [OK]
Common Mistakes:
Trying to mutate props directly
Confusing props with state usage
Ignoring React's immutability rules
5. You want to create a component that shows a user's name and allows updating it inside the component. Which approach correctly respects that props are read-only?
hard
A. Modify the props.name directly inside the component to update the name.
B. Use a global variable to store the name and ignore props.
C. Copy props.name to a state variable and update the state to change the name.
D. Pass a new name prop from the child component to the parent.
Solution
Step 1: Understand props immutability
Props cannot be changed inside the component; they are read-only.
Step 2: Use state for data that changes
Copy the prop value to a state variable, then update the state to reflect changes.
Final Answer:
Copy props.name to a state variable and update the state to change the name. -> Option C
Quick Check:
Use state to update data, not props = C [OK]
Hint: Use state for changes, keep props read-only [OK]
Common Mistakes:
Trying to change props directly
Using global variables instead of state
Passing props from child to parent (not possible)
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.