React.js • Chapter 28 • Foundations to Advanced
Portals
Study each React concept through explanations, focused examples, code, reasoning, expected behavior, practice, and review.
28.1 What a Portal Does
A portal renders children into another DOM location while preserving their position in the React component tree. In Chapter 28, the purpose is to make the behavior observable rather than memorizing an API. Follow the value from its source through the component tree and identify what React needs in order to produce the next interface. This section 28.1 connects the idea directly to Portals.
For What a Portal Does, inspect inputs, component ownership, visible output, edge cases, and the reason another render occurs. A reliable React design makes ownership explicit, keeps rendering predictable, and separates calculations from synchronization with external systems. When a feature seems complicated, reduce it to one component, one state change, or one boundary and rebuild from that verified behavior. In Portals, keep the What a Portal Does responsibility visible while you test it.
This topic emphasizes structure. Use complete states for loading, success, empty data, and failure when those states can occur. After the example works, explain why React rendered what you see and which change would cause another render; that reasoning is more valuable than copying syntax. For section 28.1, relate that explanation back to What a Portal Does.
Key terms in plain language
- Rendering work — the calculations and DOM updates required to keep the interface synchronized.
- What — a focused part of what a portal does used to describe one responsibility, input, rendering decision, or boundary in the interface.
- Portal — a focused part of what a portal does used to describe one responsibility, input, rendering decision, or boundary in the interface.
- Does — a focused part of what a portal does used to describe one responsibility, input, rendering decision, or boundary in the interface.
10 teaching examples
Example 1: Production review
Assume the Task board feature using What a Portal Does ships to many devices and languages. Review error recovery, loading states, accessibility, RTL layout, small-screen width, security boundaries, and whether monitoring can reveal failures.
Example 2: Smallest useful case
Create the smallest working version of What a Portal Does inside a Lesson tracker. Keep one input and one visible result, then describe inputs, component ownership, visible output, edge cases, and the reason another render occurs. This gives you a baseline before extra features hide the important behavior. A portal renders children into another DOM location while preserving their position in the React component tree.
Example 3: Change one input
Keep the Course catalog example stable but change one input that affects What a Portal Does. Predict what React will render before running the code, then compare the result with your prediction and explain the render path.
Example 4: Two-component comparison
Build one version of the Profile settings with the What a Portal Does responsibility in the parent and another with it in the child. Compare data ownership, reuse, and how many components need to know about the decision. A portal renders children into another DOM location while preserving their position in the React component tree.
Example 5: Failure or edge case
Create a safe edge case for What a Portal Does in the Search panel: empty data, a missing prop, a rejected request, rapid clicks, or an unmounted element. Show the user a clear state instead of allowing confusing or stale output.
Example 6: Accessibility check
Use What a Portal Does in the Shopping cart while testing keyboard access, semantic markup, labels, focus order, and understandable status feedback. React does not replace browser accessibility rules, so verify the generated interface.
Example 7: State ownership check
For the Dashboard filter, identify which component truly owns the information involved in What a Portal Does. Remove duplicated state and derive values during rendering when they can be calculated from existing props or state. A portal renders children into another DOM location while preserving their position in the React component tree.
Example 8: Network-delay scenario
Assume the Message composer is waiting on a slow API while using What a Portal Does. Decide what stays interactive, what shows pending feedback, what can be cancelled, and how stale responses are prevented from replacing newer data.
Example 9: Refactoring exercise
Take a large Appointment form component that mixes What a Portal Does with unrelated concerns. Extract one focused component or custom hook, give it a narrow API, and confirm that the user-visible behavior stays the same.
Example 10: Performance experiment
Profile the Photo gallery before optimizing What a Portal Does. Record which components render, what calculation is costly, and whether the delay is actually noticeable; apply an optimization only when the measurement supports it. A portal renders children into another DOM location while preserving their position in the React component tree.
React coding example
import { createPortal } from 'react-dom';
export default function Modal({ open, onClose }) {
if (!open) return null;
return createPortal(
<div role="dialog" aria-modal="true" aria-label="Example dialog">
<button onClick={onClose}>Close</button>
</div>,
document.body
);
}Step-by-step code explanation
- Identify the responsibility demonstrated by What a Portal Does.
- Read the component from inputs to returned JSX before focusing on individual syntax.
- Trace which event, prop, promise, or state update can cause the visible result to change.
- Test one normal path and one edge case so the behavior is not inferred from the happy path alone.
- Keep the example small enough that you can explain every render and every external side effect.
Expected behavior: A small React interface demonstrating What a Portal Does; the exact browser text depends on the interaction or data used in the example.
Practice exercise
Create a small interface focused on What a Portal Does. Write the expected screen state before running it, test one edge case, and change one input or interaction. Then explain which component owns the relevant data, what caused the render, and one accessibility or small-screen check you would perform before shipping the feature. Record the result as the Chapter 28 practice for Portals.
28.2 Rendering Modal Content
Rendering Modal Content is best understood through rendering work: the calculations and DOM updates required to keep the interface synchronized. Focus on measurement, scheduling, memoization, fallback UI, and user-perceived responsiveness. In Chapter 28, the purpose is to make the behavior observable rather than memorizing an API. Follow the value from its source through the component tree and identify what React needs in order to produce the next interface. This section 28.2 connects the idea directly to Portals.
For Rendering Modal Content, inspect render frequency, prop identity, measured cost, scheduling, and user-visible responsiveness. A reliable React design makes ownership explicit, keeps rendering predictable, and separates calculations from synchronization with external systems. When a feature seems complicated, reduce it to one component, one state change, or one boundary and rebuild from that verified behavior. In Portals, keep the Rendering Modal Content responsibility visible while you test it.
This topic emphasizes data flow. Use complete states for loading, success, empty data, and failure when those states can occur. After the example works, explain why React rendered what you see and which change would cause another render; that reasoning is more valuable than copying syntax. For section 28.2, relate that explanation back to Rendering Modal Content.
Key terms in plain language
- Rendering work — the calculations and DOM updates required to keep the interface synchronized.
- Rendering — a focused part of rendering modal content used to describe one responsibility, input, rendering decision, or boundary in the interface.
- Modal — a focused part of rendering modal content used to describe one responsibility, input, rendering decision, or boundary in the interface.
- Content — a focused part of rendering modal content used to describe one responsibility, input, rendering decision, or boundary in the interface.
10 teaching examples
Example 1: Smallest useful case
Create the smallest working version of Rendering Modal Content inside a Search panel. Keep one input and one visible result, then describe render frequency, prop identity, measured cost, scheduling, and user-visible responsiveness. This gives you a baseline before extra features hide the important behavior. Rendering Modal Content is best understood through rendering work: the calculations and DOM updates required to keep the interface synchronized. Focus on measurement, scheduling, memoization, fallback UI, and user-perceived responsiveness.
Example 2: Change one input
Keep the Shopping cart example stable but change one input that affects Rendering Modal Content. Predict what React will render before running the code, then compare the result with your prediction and explain the render path.
Example 3: Two-component comparison
Build one version of the Dashboard filter with the Rendering Modal Content responsibility in the parent and another with it in the child. Compare data ownership, reuse, and how many components need to know about the decision. Rendering Modal Content is best understood through rendering work: the calculations and DOM updates required to keep the interface synchronized. Focus on measurement, scheduling, memoization, fallback UI, and user-perceived responsiveness.
Example 4: Failure or edge case
Create a safe edge case for Rendering Modal Content in the Message composer: empty data, a missing prop, a rejected request, rapid clicks, or an unmounted element. Show the user a clear state instead of allowing confusing or stale output.
Example 5: Accessibility check
Use Rendering Modal Content in the Appointment form while testing keyboard access, semantic markup, labels, focus order, and understandable status feedback. React does not replace browser accessibility rules, so verify the generated interface.
Example 6: State ownership check
For the Photo gallery, identify which component truly owns the information involved in Rendering Modal Content. Remove duplicated state and derive values during rendering when they can be calculated from existing props or state. Rendering Modal Content is best understood through rendering work: the calculations and DOM updates required to keep the interface synchronized. Focus on measurement, scheduling, memoization, fallback UI, and user-perceived responsiveness.
Example 7: Network-delay scenario
Assume the Task board is waiting on a slow API while using Rendering Modal Content. Decide what stays interactive, what shows pending feedback, what can be cancelled, and how stale responses are prevented from replacing newer data.
Example 8: Refactoring exercise
Take a large Notification center component that mixes Rendering Modal Content with unrelated concerns. Extract one focused component or custom hook, give it a narrow API, and confirm that the user-visible behavior stays the same.
Example 9: Performance experiment
Profile the Quiz screen before optimizing Rendering Modal Content. Record which components render, what calculation is costly, and whether the delay is actually noticeable; apply an optimization only when the measurement supports it. Rendering Modal Content is best understood through rendering work: the calculations and DOM updates required to keep the interface synchronized. Focus on measurement, scheduling, memoization, fallback UI, and user-perceived responsiveness.
Example 10: Production review
Assume the Language selector feature using Rendering Modal Content ships to many devices and languages. Review error recovery, loading states, accessibility, RTL layout, small-screen width, security boundaries, and whether monitoring can reveal failures.
React coding example
import { createPortal } from 'react-dom';
export default function Modal({ open, onClose }) {
if (!open) return null;
return createPortal(
<div role="dialog" aria-modal="true" aria-label="Example dialog">
<button onClick={onClose}>Close</button>
</div>,
document.body
);
}Step-by-step code explanation
- Identify the responsibility demonstrated by Rendering Modal Content.
- Read the component from inputs to returned JSX before focusing on individual syntax.
- Trace which event, prop, promise, or state update can cause the visible result to change.
- Test one normal path and one edge case so the behavior is not inferred from the happy path alone.
- Keep the example small enough that you can explain every render and every external side effect.
Expected behavior: A small React interface demonstrating Rendering Modal Content; the exact browser text depends on the interaction or data used in the example.
Practice exercise
Create a small interface focused on Rendering Modal Content. Write the expected screen state before running it, test one edge case, and change one input or interaction. Then explain which component owns the relevant data, what caused the render, and one accessibility or small-screen check you would perform before shipping the feature. Record the result as the Chapter 28 practice for Portals.
28.3 Event Behavior Through Portals
A portal renders children into another DOM location while preserving their position in the React component tree. In Chapter 28, the purpose is to make the behavior observable rather than memorizing an API. Follow the value from its source through the component tree and identify what React needs in order to produce the next interface. This section 28.3 connects the idea directly to Portals.
For Event Behavior Through Portals, inspect the event source, handler reference, propagation path, and state updates caused by the event. A reliable React design makes ownership explicit, keeps rendering predictable, and separates calculations from synchronization with external systems. When a feature seems complicated, reduce it to one component, one state change, or one boundary and rebuild from that verified behavior. In Portals, keep the Event Behavior Through Portals responsibility visible while you test it.
This topic emphasizes edge cases. Use complete states for loading, success, empty data, and failure when those states can occur. After the example works, explain why React rendered what you see and which change would cause another render; that reasoning is more valuable than copying syntax. For section 28.3, relate that explanation back to Event Behavior Through Portals.
Key terms in plain language
- Rendering work — the calculations and DOM updates required to keep the interface synchronized.
- Event — a focused part of event behavior through portals used to describe one responsibility, input, rendering decision, or boundary in the interface.
- Behavior — a focused part of event behavior through portals used to describe one responsibility, input, rendering decision, or boundary in the interface.
- Through — a focused part of event behavior through portals used to describe one responsibility, input, rendering decision, or boundary in the interface.
10 teaching examples
Example 1: Change one input
Keep the Appointment form example stable but change one input that affects Event Behavior Through Portals. Predict what React will render before running the code, then compare the result with your prediction and explain the render path.
Example 2: Two-component comparison
Build one version of the Photo gallery with the Event Behavior Through Portals responsibility in the parent and another with it in the child. Compare data ownership, reuse, and how many components need to know about the decision. A portal renders children into another DOM location while preserving their position in the React component tree.
Example 3: Failure or edge case
Create a safe edge case for Event Behavior Through Portals in the Task board: empty data, a missing prop, a rejected request, rapid clicks, or an unmounted element. Show the user a clear state instead of allowing confusing or stale output.
Example 4: Accessibility check
Use Event Behavior Through Portals in the Notification center while testing keyboard access, semantic markup, labels, focus order, and understandable status feedback. React does not replace browser accessibility rules, so verify the generated interface.
Example 5: State ownership check
For the Quiz screen, identify which component truly owns the information involved in Event Behavior Through Portals. Remove duplicated state and derive values during rendering when they can be calculated from existing props or state. A portal renders children into another DOM location while preserving their position in the React component tree.
Example 6: Network-delay scenario
Assume the Language selector is waiting on a slow API while using Event Behavior Through Portals. Decide what stays interactive, what shows pending feedback, what can be cancelled, and how stale responses are prevented from replacing newer data.
Example 7: Refactoring exercise
Take a large Account menu component that mixes Event Behavior Through Portals with unrelated concerns. Extract one focused component or custom hook, give it a narrow API, and confirm that the user-visible behavior stays the same.
Example 8: Performance experiment
Profile the Data table before optimizing Event Behavior Through Portals. Record which components render, what calculation is costly, and whether the delay is actually noticeable; apply an optimization only when the measurement supports it. A portal renders children into another DOM location while preserving their position in the React component tree.
Example 9: Production review
Assume the Upload panel feature using Event Behavior Through Portals ships to many devices and languages. Review error recovery, loading states, accessibility, RTL layout, small-screen width, security boundaries, and whether monitoring can reveal failures.
Example 10: Smallest useful case
Create the smallest working version of Event Behavior Through Portals inside a Message composer. Keep one input and one visible result, then describe the event source, handler reference, propagation path, and state updates caused by the event. This gives you a baseline before extra features hide the important behavior. A portal renders children into another DOM location while preserving their position in the React component tree.
React coding example
import { createPortal } from 'react-dom';
export default function Modal({ open, onClose }) {
if (!open) return null;
return createPortal(
<div role="dialog" aria-modal="true" aria-label="Example dialog">
<button onClick={onClose}>Close</button>
</div>,
document.body
);
}Step-by-step code explanation
- Identify the responsibility demonstrated by Event Behavior Through Portals.
- Read the component from inputs to returned JSX before focusing on individual syntax.
- Trace which event, prop, promise, or state update can cause the visible result to change.
- Test one normal path and one edge case so the behavior is not inferred from the happy path alone.
- Keep the example small enough that you can explain every render and every external side effect.
Expected behavior: A small React interface demonstrating Event Behavior Through Portals; the exact browser text depends on the interaction or data used in the example.
Practice exercise
Create a small interface focused on Event Behavior Through Portals. Write the expected screen state before running it, test one edge case, and change one input or interaction. Then explain which component owns the relevant data, what caused the render, and one accessibility or small-screen check you would perform before shipping the feature. Record the result as the Chapter 28 practice for Portals.
28.4 Accessible Dialog Structure
Accessible Dialog Structure is best understood through rendering work: the calculations and DOM updates required to keep the interface synchronized. Focus on measurement, scheduling, memoization, fallback UI, and user-perceived responsiveness. In Chapter 28, the purpose is to make the behavior observable rather than memorizing an API. Follow the value from its source through the component tree and identify what React needs in order to produce the next interface. This section 28.4 connects the idea directly to Portals.
For Accessible Dialog Structure, inspect inputs, component ownership, visible output, edge cases, and the reason another render occurs. A reliable React design makes ownership explicit, keeps rendering predictable, and separates calculations from synchronization with external systems. When a feature seems complicated, reduce it to one component, one state change, or one boundary and rebuild from that verified behavior. In Portals, keep the Accessible Dialog Structure responsibility visible while you test it.
This topic emphasizes accessibility. Use complete states for loading, success, empty data, and failure when those states can occur. After the example works, explain why React rendered what you see and which change would cause another render; that reasoning is more valuable than copying syntax. For section 28.4, relate that explanation back to Accessible Dialog Structure.
Key terms in plain language
- Rendering work — the calculations and DOM updates required to keep the interface synchronized.
- Accessible — a focused part of accessible dialog structure used to describe one responsibility, input, rendering decision, or boundary in the interface.
- Dialog — a focused part of accessible dialog structure used to describe one responsibility, input, rendering decision, or boundary in the interface.
- Structure — a focused part of accessible dialog structure used to describe one responsibility, input, rendering decision, or boundary in the interface.
10 teaching examples
Example 1: Two-component comparison
Build one version of the Quiz screen with the Accessible Dialog Structure responsibility in the parent and another with it in the child. Compare data ownership, reuse, and how many components need to know about the decision. Accessible Dialog Structure is best understood through rendering work: the calculations and DOM updates required to keep the interface synchronized. Focus on measurement, scheduling, memoization, fallback UI, and user-perceived responsiveness.
Example 2: Failure or edge case
Create a safe edge case for Accessible Dialog Structure in the Language selector: empty data, a missing prop, a rejected request, rapid clicks, or an unmounted element. Show the user a clear state instead of allowing confusing or stale output.
Example 3: Accessibility check
Use Accessible Dialog Structure in the Account menu while testing keyboard access, semantic markup, labels, focus order, and understandable status feedback. React does not replace browser accessibility rules, so verify the generated interface.
Example 4: State ownership check
For the Data table, identify which component truly owns the information involved in Accessible Dialog Structure. Remove duplicated state and derive values during rendering when they can be calculated from existing props or state. Accessible Dialog Structure is best understood through rendering work: the calculations and DOM updates required to keep the interface synchronized. Focus on measurement, scheduling, memoization, fallback UI, and user-perceived responsiveness.
Example 5: Network-delay scenario
Assume the Upload panel is waiting on a slow API while using Accessible Dialog Structure. Decide what stays interactive, what shows pending feedback, what can be cancelled, and how stale responses are prevented from replacing newer data.
Example 6: Refactoring exercise
Take a large Team roster component that mixes Accessible Dialog Structure with unrelated concerns. Extract one focused component or custom hook, give it a narrow API, and confirm that the user-visible behavior stays the same.
Example 7: Performance experiment
Profile the Analytics card before optimizing Accessible Dialog Structure. Record which components render, what calculation is costly, and whether the delay is actually noticeable; apply an optimization only when the measurement supports it. Accessible Dialog Structure is best understood through rendering work: the calculations and DOM updates required to keep the interface synchronized. Focus on measurement, scheduling, memoization, fallback UI, and user-perceived responsiveness.
Example 8: Production review
Assume the Booking flow feature using Accessible Dialog Structure ships to many devices and languages. Review error recovery, loading states, accessibility, RTL layout, small-screen width, security boundaries, and whether monitoring can reveal failures.
Example 9: Smallest useful case
Create the smallest working version of Accessible Dialog Structure inside a Task board. Keep one input and one visible result, then describe inputs, component ownership, visible output, edge cases, and the reason another render occurs. This gives you a baseline before extra features hide the important behavior. Accessible Dialog Structure is best understood through rendering work: the calculations and DOM updates required to keep the interface synchronized. Focus on measurement, scheduling, memoization, fallback UI, and user-perceived responsiveness.
Example 10: Change one input
Keep the Notification center example stable but change one input that affects Accessible Dialog Structure. Predict what React will render before running the code, then compare the result with your prediction and explain the render path.
React coding example
import { createPortal } from 'react-dom';
export default function Modal({ open, onClose }) {
if (!open) return null;
return createPortal(
<div role="dialog" aria-modal="true" aria-label="Example dialog">
<button onClick={onClose}>Close</button>
</div>,
document.body
);
}Step-by-step code explanation
- Identify the responsibility demonstrated by Accessible Dialog Structure.
- Read the component from inputs to returned JSX before focusing on individual syntax.
- Trace which event, prop, promise, or state update can cause the visible result to change.
- Test one normal path and one edge case so the behavior is not inferred from the happy path alone.
- Keep the example small enough that you can explain every render and every external side effect.
Expected behavior: A small React interface demonstrating Accessible Dialog Structure; the exact browser text depends on the interaction or data used in the example.
Practice exercise
Create a small interface focused on Accessible Dialog Structure. Write the expected screen state before running it, test one edge case, and change one input or interaction. Then explain which component owns the relevant data, what caused the render, and one accessibility or small-screen check you would perform before shipping the feature. Record the result as the Chapter 28 practice for Portals.
28.5 Choosing a Portal Container
A portal renders children into another DOM location while preserving their position in the React component tree. In Chapter 28, the purpose is to make the behavior observable rather than memorizing an API. Follow the value from its source through the component tree and identify what React needs in order to produce the next interface. This section 28.5 connects the idea directly to Portals.
For Choosing a Portal Container, inspect inputs, component ownership, visible output, edge cases, and the reason another render occurs. A reliable React design makes ownership explicit, keeps rendering predictable, and separates calculations from synchronization with external systems. When a feature seems complicated, reduce it to one component, one state change, or one boundary and rebuild from that verified behavior. In Portals, keep the Choosing a Portal Container responsibility visible while you test it.
This topic emphasizes production behavior. Use complete states for loading, success, empty data, and failure when those states can occur. After the example works, explain why React rendered what you see and which change would cause another render; that reasoning is more valuable than copying syntax. For section 28.5, relate that explanation back to Choosing a Portal Container.
Key terms in plain language
- Rendering work — the calculations and DOM updates required to keep the interface synchronized.
- Choosing — a focused part of choosing a portal container used to describe one responsibility, input, rendering decision, or boundary in the interface.
- Portal — a focused part of choosing a portal container used to describe one responsibility, input, rendering decision, or boundary in the interface.
- Container — a focused part of choosing a portal container used to describe one responsibility, input, rendering decision, or boundary in the interface.
10 teaching examples
Example 1: Failure or edge case
Create a safe edge case for Choosing a Portal Container in the Upload panel: empty data, a missing prop, a rejected request, rapid clicks, or an unmounted element. Show the user a clear state instead of allowing confusing or stale output.
Example 2: Accessibility check
Use Choosing a Portal Container in the Team roster while testing keyboard access, semantic markup, labels, focus order, and understandable status feedback. React does not replace browser accessibility rules, so verify the generated interface.
Example 3: State ownership check
For the Analytics card, identify which component truly owns the information involved in Choosing a Portal Container. Remove duplicated state and derive values during rendering when they can be calculated from existing props or state. A portal renders children into another DOM location while preserving their position in the React component tree.
Example 4: Network-delay scenario
Assume the Booking flow is waiting on a slow API while using Choosing a Portal Container. Decide what stays interactive, what shows pending feedback, what can be cancelled, and how stale responses are prevented from replacing newer data.
Example 5: Refactoring exercise
Take a large Support ticket component that mixes Choosing a Portal Container with unrelated concerns. Extract one focused component or custom hook, give it a narrow API, and confirm that the user-visible behavior stays the same.
Example 6: Performance experiment
Profile the Lesson tracker before optimizing Choosing a Portal Container. Record which components render, what calculation is costly, and whether the delay is actually noticeable; apply an optimization only when the measurement supports it. A portal renders children into another DOM location while preserving their position in the React component tree.
Example 7: Production review
Assume the Course catalog feature using Choosing a Portal Container ships to many devices and languages. Review error recovery, loading states, accessibility, RTL layout, small-screen width, security boundaries, and whether monitoring can reveal failures.
Example 8: Smallest useful case
Create the smallest working version of Choosing a Portal Container inside a Language selector. Keep one input and one visible result, then describe inputs, component ownership, visible output, edge cases, and the reason another render occurs. This gives you a baseline before extra features hide the important behavior. A portal renders children into another DOM location while preserving their position in the React component tree.
Example 9: Change one input
Keep the Account menu example stable but change one input that affects Choosing a Portal Container. Predict what React will render before running the code, then compare the result with your prediction and explain the render path.
Example 10: Two-component comparison
Build one version of the Data table with the Choosing a Portal Container responsibility in the parent and another with it in the child. Compare data ownership, reuse, and how many components need to know about the decision. A portal renders children into another DOM location while preserving their position in the React component tree.
React coding example
import { createPortal } from 'react-dom';
export default function Modal({ open, onClose }) {
if (!open) return null;
return createPortal(
<div role="dialog" aria-modal="true" aria-label="Example dialog">
<button onClick={onClose}>Close</button>
</div>,
document.body
);
}Step-by-step code explanation
- Identify the responsibility demonstrated by Choosing a Portal Container.
- Read the component from inputs to returned JSX before focusing on individual syntax.
- Trace which event, prop, promise, or state update can cause the visible result to change.
- Test one normal path and one edge case so the behavior is not inferred from the happy path alone.
- Keep the example small enough that you can explain every render and every external side effect.
Expected behavior: A small React interface demonstrating Choosing a Portal Container; the exact browser text depends on the interaction or data used in the example.
Practice exercise
Create a small interface focused on Choosing a Portal Container. Write the expected screen state before running it, test one edge case, and change one input or interaction. Then explain which component owns the relevant data, what caused the render, and one accessibility or small-screen check you would perform before shipping the feature. Record the result as the Chapter 28 practice for Portals.
Chapter 28 review — 20 questions and answers
1. What problem does What a Portal Does help solve in this chapter?
Answer: A portal renders children into another DOM location while preserving their position in the React component tree.
2. What should you inspect when What a Portal Does does not behave as expected?
Answer: Check inputs, component ownership, visible output, edge cases, and the reason another render occurs. Reduce the example until you can identify the input, render decision, update, and visible result.
3. How can you practice What a Portal Does without copying a large application?
Answer: Build a small component focused on What a Portal Does, predict its output, change one condition, and explain why React renders the new result.
4. What production concern belongs with What a Portal Does?
Answer: Review error recovery, accessibility, performance, security boundaries, localization, and small-screen behavior according to what What a Portal Does touches.
5. What problem does Rendering Modal Content help solve in this chapter?
Answer: Rendering Modal Content is best understood through rendering work: the calculations and DOM updates required to keep the interface synchronized. Focus on measurement, scheduling, memoization, fallback UI, and user-perceived responsiveness.
6. What should you inspect when Rendering Modal Content does not behave as expected?
Answer: Check render frequency, prop identity, measured cost, scheduling, and user-visible responsiveness. Reduce the example until you can identify the input, render decision, update, and visible result.
7. How can you practice Rendering Modal Content without copying a large application?
Answer: Build a small component focused on Rendering Modal Content, predict its output, change one condition, and explain why React renders the new result.
8. What production concern belongs with Rendering Modal Content?
Answer: Review error recovery, accessibility, performance, security boundaries, localization, and small-screen behavior according to what Rendering Modal Content touches.
9. What problem does Event Behavior Through Portals help solve in this chapter?
Answer: A portal renders children into another DOM location while preserving their position in the React component tree.
10. What should you inspect when Event Behavior Through Portals does not behave as expected?
Answer: Check the event source, handler reference, propagation path, and state updates caused by the event. Reduce the example until you can identify the input, render decision, update, and visible result.
11. How can you practice Event Behavior Through Portals without copying a large application?
Answer: Build a small component focused on Event Behavior Through Portals, predict its output, change one condition, and explain why React renders the new result.
12. What production concern belongs with Event Behavior Through Portals?
Answer: Review error recovery, accessibility, performance, security boundaries, localization, and small-screen behavior according to what Event Behavior Through Portals touches.
13. What problem does Accessible Dialog Structure help solve in this chapter?
Answer: Accessible Dialog Structure is best understood through rendering work: the calculations and DOM updates required to keep the interface synchronized. Focus on measurement, scheduling, memoization, fallback UI, and user-perceived responsiveness.
14. What should you inspect when Accessible Dialog Structure does not behave as expected?
Answer: Check inputs, component ownership, visible output, edge cases, and the reason another render occurs. Reduce the example until you can identify the input, render decision, update, and visible result.
15. How can you practice Accessible Dialog Structure without copying a large application?
Answer: Build a small component focused on Accessible Dialog Structure, predict its output, change one condition, and explain why React renders the new result.
16. What production concern belongs with Accessible Dialog Structure?
Answer: Review error recovery, accessibility, performance, security boundaries, localization, and small-screen behavior according to what Accessible Dialog Structure touches.
17. What problem does Choosing a Portal Container help solve in this chapter?
Answer: A portal renders children into another DOM location while preserving their position in the React component tree.
18. What should you inspect when Choosing a Portal Container does not behave as expected?
Answer: Check inputs, component ownership, visible output, edge cases, and the reason another render occurs. Reduce the example until you can identify the input, render decision, update, and visible result.
19. How can you practice Choosing a Portal Container without copying a large application?
Answer: Build a small component focused on Choosing a Portal Container, predict its output, change one condition, and explain why React renders the new result.
20. What production concern belongs with Choosing a Portal Container?
Answer: Review error recovery, accessibility, performance, security boundaries, localization, and small-screen behavior according to what Choosing a Portal Container touches.