21. Based on the code below, is the userName variable external or internal data of the DisplayUser component?
function DisplayUser(props) {
return (
< h1>{props.userName}< /h1>
);
}
- The userName value is data that is external to the DisplayUser component
- The userName value is data that is internal to the DisplayUser component
Knowledge check: Passing state
22. What is the Context API?
- A way to change the execution context of a function in JavaScript.
- An alternative way to working with state in React.
23. When working with useState to keep state in a variable, you should not use array destructuring.
- True
- False
24. If a state variable is destructured from useState, and set to variable name of user, the name of the function to update the user state variable should be...
- userSetter
- useUser
- useState
- setUser
25. What does the concept of “lifting up state” entail?
- It involves moving the state from the parent component to the child component.
- It involves moving the state from the child component to the parent component.
26. What is a negative result of lifting up state in a React app?
- Prop drilling.
- It can significantly increase the number of components that you need to create.
- There are no negatives from lifting up state in React.
Knowledge check: State or stateless
27. What is a stateless component?
- A component that doesn’t track its parent’s state.
- A component that doesn’t track its own state.
Shuffle Q/A 3
29. To turn a stateless component into a stateful component, you must pass it a props object.
- True
- False
30. The process of lifting up state can lead to:
Select all that apply.
- A stateful child component controlling the state of a stateless parent component.
- A stateless component becoming a stateful component.
- A stateful child component controlling the state of a stateful parent component.
- A stateful component becoming a stateless component.