The Mental Model — UI as a Function of State — Concept Check
Questions on The Mental Model — UI as a Function of State. You describe what the screen should look like for a given state, and React works out what to change. You never write the change itself — that inversion is the whole framework.
Questions in this quiz
8 questions on The Mental Model — UI as a Function of State — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A React component is not updating when its state changes. What might be the problem?
- AThe component is a class component.
- BThe state is not being set correctly.
- CThe component is using two-way data binding.
- DThe component is missing a render method.
2.In a React application, you notice that a child component is directly modifying a prop. What is the likely issue?
- AThe component is using two-way data binding.
- BThe component is incorrectly handling state.
- CThe component is missing lifecycle methods.
- DThe application is using an outdated React version.
3.A developer is using React and finds themselves frequently manipulating the DOM directly. What does this indicate?
- AThey are using class components instead of function components.
- BThey have missing state management in their application.
- CThey are implementing server-side rendering incorrectly.
- DThey are using React Router incorrectly.
4.What happens when a React component's state is updated?
- AThe component re-renders if the state changes.
- BThe component unmounts and remounts.
- CThe component's lifecycle methods are reset.
- DThe component's props are automatically updated.
5.A React component is supposed to display a loading spinner, but it doesn't appear. What might be missing?
- AThe component is missing a key prop.
- BThe component is not using a state to track loading.
- CThe component is not using useEffect.
- DThe component is incorrectly using two-way data binding.
6.In React, why is one-way data flow preferred over two-way data binding?
- AIt reduces the need for state management.
- BIt allows components to automatically update props.
- CIt ensures faster rendering of components.
- DIt simplifies tracking data changes and debugging.
7.A team is starting a new project using Vite + React. What does this setup imply?
- AThey are relying on Next.js for server rendering.
- BThey will handle routing and data fetching manually.
- CThey are using class components for new code.
- DThey are using server-side rendering by default.
8.How does React handle UI updates when the application state changes?
- AReact recalculates the UI from scratch based on the new state.
- BReact uses two-way data binding to sync the UI and state.
- CReact requires manual DOM updates for each state change.
- DReact updates the UI by directly manipulating the DOM.