Components and Props — Concept Check
Questions on Components and Props. A component is a function taking props and returning UI. Props are read-only inputs, and treating them as read-only is what keeps a React app predictable.
Questions in this quiz
7 questions on Components and Props — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.You have a React component that modifies a prop directly. What is a likely consequence?
- AThe component will re-render continuously.
- BThe component will not render at all.
- CThe prop will automatically reset.
- DThe app may behave unpredictably.
2.A component is defined inside another component and uses state. What issue might arise?
- AIt will share state with the parent.
- BIt will have improved performance.
- CIt will lose its state on re-render.
- DIt will not render at all.
3.In React, why is it recommended to use children for composition over adding more boolean props?
- AIt reduces the number of renders.
- BIt prevents state loss.
- CIt simplifies component logic.
- DIt makes components more reusable.
4.You notice a component with many boolean props like showHeader and hideIcon. What should you consider doing?
- AAdd more props for clarity.
- BLeave it as is for simplicity.
- CRefactor to use children for composition.
- DCombine the props into a single object.
5.What happens if you destructure props in the function signature but do not provide a default value?
- AProps will be set to an empty object.
- BThe component will not render.
- CIt may lead to undefined props.
- DProps will automatically be null.
6.A developer copies an array prop and sorts it inside a component. What is the benefit of this approach?
- AIt automatically updates the parent component.
- BIt reduces memory usage.
- CIt simplifies the sorting logic.
- DIt prevents mutation of the original array.
7.Why should a component be split if it is used in more than one place?
- ATo reduce file size.
- BTo enhance code reusability.
- CTo improve rendering speed.
- DTo simplify state management.