Module quiz: Data and state
32. In React, data flows in one way: from a parent component to a child component.
- True
- FalseÂ
33. Why is one-way data flow important in React?
- It ensures that the data is flowing from top to bottom in the component hierarchy.
- It ensures that the data is flowing from bottom to top in the component hierarchy.
34. True or false? State data is the data inside a component that a component can mutate.
- True
- False
35. What is prop drilling?
- Prop drilling is a situation where you are passing data from a parent to a child component, then to a grandchild component, and so on, until it reaches a more distant component further down the component tree, where this data is required
- Prop drilling is a situation where you are passing data from a child, to a parent component, then to a grandparent component, and so on, until it reaches a more distant component further up the component tree, where this data is required.
36. The distinction between stateful and stateless components is that the latter doesn't have its own state.
- True
- False
37. Choose the correct statement.
- Remember that you should always change the values of props in children components; you should never work with them as they are. In other words, props are mutable.
- Remember that you should never change the values of props in children components; you should only work with them as they are. In other words, props are immutable.
38. Is this code valid?
function App() {
const handler = () => console.log('fourth example')
return (
< div>
< button onClick = {handler} >
Click Me!
< /button>
< /div>
)
}
export default App
- Yes
- No
Shuffle Q/A 4
39. Is this code valid?
< button onClick={ () => console.log('clicked') }>
Click me
< /button>
- Yes
- NoÂ
40. Select the correct statement: The useState hook...
- … lets you hook into React state and lifecycle features from a component.
- …is not part of React; you must import it from a third-party package.
- … has a convention that if the state variable is named, for example, counter, the function to update this counter variable should be named counterFunction.
- … should never be called at the top level of a React component.