CSCI 4300 NEW FINAL EXAM WITH QUESTIONS AND
100% CORRECT ANSWERS
What is reconciliation?
Figuring out which changes need to be made to keep everything updated
What is separation of concerns?
Organizing code by distinct responsibilities (e.g., separating UI components and logic)
What is the virtual DOM?
Lightweight representation of the real DOM; React updates the Virtual DOM first for
efficiency
What is a prop?
A way to pass data from a parent component to a child component
True or False: Props are read-only and cannot be modified by the child component.
True
True or False: Props can only be passed down, not up.
True
What are the steps to using a prop in a child component?
1. Pass prop into child component in parent file
2. Pass prop as parameter of child component in child file
, True or False: You cannot destructure props.
False
What is the special prop, children?
Reserved prop used to pass nested components/elements to a component
What is the purpose of the children prop?
You don't have to hardcode anything in. Anything inside can be changed.
What is a state?
Dynamic data that can change in a component
How to initialize a state?
Use following format inside component function:
const [item, setItem] = useState(initialValue);
How to update state by a button click?
<button onClick={setItem}>Click</button>
What is the purpose of states in React?
Manage component-specific, dynamic data
What are the 3 main hooks used in React? What is the role of each hook?
useState = manages local state in functional components
useEffect = handles side effects (e.g. fetching data, directly updating DOM, timers, etc.)
useContext = a way to manage states globally
100% CORRECT ANSWERS
What is reconciliation?
Figuring out which changes need to be made to keep everything updated
What is separation of concerns?
Organizing code by distinct responsibilities (e.g., separating UI components and logic)
What is the virtual DOM?
Lightweight representation of the real DOM; React updates the Virtual DOM first for
efficiency
What is a prop?
A way to pass data from a parent component to a child component
True or False: Props are read-only and cannot be modified by the child component.
True
True or False: Props can only be passed down, not up.
True
What are the steps to using a prop in a child component?
1. Pass prop into child component in parent file
2. Pass prop as parameter of child component in child file
, True or False: You cannot destructure props.
False
What is the special prop, children?
Reserved prop used to pass nested components/elements to a component
What is the purpose of the children prop?
You don't have to hardcode anything in. Anything inside can be changed.
What is a state?
Dynamic data that can change in a component
How to initialize a state?
Use following format inside component function:
const [item, setItem] = useState(initialValue);
How to update state by a button click?
<button onClick={setItem}>Click</button>
What is the purpose of states in React?
Manage component-specific, dynamic data
What are the 3 main hooks used in React? What is the role of each hook?
useState = manages local state in functional components
useEffect = handles side effects (e.g. fetching data, directly updating DOM, timers, etc.)
useContext = a way to manage states globally