🌍 ReactJS · flashcards
ReactJS Advanced Concepts Flashcards
50 question-and-answer cards covering Advanced Concepts as it is examined in ReactJS. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.
24 sample cards from the Advanced Concepts deck
Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.
What is a React Portal?
A Portal is a way to render children into a DOM node that exists outside the DOM hierarchy of the parent component, while keeping them in the React component tree.
What is the API signature for creating a Portal?
ReactDOM.createPortal(children, container), where children is any renderable React child and container is the target DOM element to render into.
Give a minimal Portal render example.
render() { return ReactDOM.createPortal(this.props.children, domNode); } where domNode is a DOM element (e.g., document.getElementById('modal-root')).
Even though a Portal renders into a different DOM node, where does it stay in the React tree?
It stays inside its parent component in the React tree, so it still has access to context, props, and the normal React data flow regardless of DOM position.
How do events propagate from a Portal?
Events bubble up through the React tree (the parent hierarchy), NOT the DOM tree. A click inside a portal can be caught by an onClick handler on the React ancestor, even though the DOM node is elsewhere.
Why is event bubbling through the React tree in portals useful?
It lets parents catch events from portaled children (e.g., a modal) as if they were regular children, enabling flexible abstractions like dialogs and tooltips that still integrate with parent logic.
What are the primary use cases for Portals?
Modals/dialogs, tooltips, popovers, dropdown menus, notifications/toasts, and hovercards — any UI that must visually break out of a container with overflow:hidden, z-index, or clipping constraints.
Why do overflow:hidden or z-index issues motivate using a Portal?
When a child is inside a container with clipped overflow or a stacking context, it can be cut off or hidden. A Portal renders it higher in the DOM (e.g., document.body) so it escapes those constraints.
What is the typical HTML setup for using a modal Portal?
Add a sibling root in index.html, e.g. <div id="root"></div><div id="modal-root"></div>, then portal the modal into #modal-root via document.getElementById('modal-root').
How does a Portal differ from simply rendering a child normally?
A normal child is inserted into the parent's DOM subtree; a Portal inserts the child into a DOM node you specify (outside the parent subtree), while preserving React-tree relationships.
What is Inheritance Inversion in HOCs?
An HOC technique where the returned component extends (class Enhanced extends WrappedComponent), allowing it to intercept lifecycle, read/hijack state and props, and conditionally control rendering via super.render().
What can Inheritance Inversion do that Props Proxy cannot easily?
Render highjacking: it can read and modify the React element tree output by the wrapped component's render, conditionally render it, and manipulate the wrapped component's state directly.
Why are HOCs considered a compile-time / static pattern versus render props being dynamic?
HOCs are typically applied once when the component is defined (static composition), while render props resolve composition dynamically during render, allowing runtime decisions about what to render.
What convention should HOCs follow regarding props they don't use ('pass-through')?
They should be transparent: pass through unrelated props unchanged via {...props}, only adding/overriding the specific props relevant to the concern they address.
When wrapping a component with an HOC, what happens to the wrapped component's state?
The wrapped component keeps its own state; the HOC can add its own separate state in the container. Reapplying the HOC in render, however, would remount and reset that state.
How can a render-prop component provide multiple values to the consumer?
By calling the render function with an object or multiple arguments, e.g. props.render({ data, loading, error }), letting the consumer destructure what it needs.
Compare HOCs and render props on 'where composition is visible.'
With render props, the composition and data flow are explicit in JSX where used. With HOCs, composition is implicit at the component's definition, so the injected props' origin can be less obvious.
What indirection/naming problem is a downside of HOCs?
Prop name collisions and hidden origins: injected props can clash or be untraceable, and the extra wrapper layers add indirection that complicates debugging.
How do you conditionally render nothing from a render-prop or HOC-based subscription while loading?
Return null (or a fallback) until data arrives: e.g. if (!data) return null; then call the render prop / render the wrapped component with the loaded data.
What must the second argument to ReactDOM.createPortal be, and can it be created dynamically?
It must be a valid DOM node (an actual Element). It can be a static node from the HTML, or one created dynamically (e.g., document.createElement('div')) and appended/removed in lifecycle or effects.
When dynamically creating a portal container node, what cleanup is required?
Append the created node to the DOM on mount (componentDidMount / useEffect) and remove it on unmount (componentWillUnmount / effect cleanup) to prevent orphaned DOM nodes.
Do portals change React's context behavior for the portaled subtree?
No. Because portals remain in the React tree, the portaled children still receive context from their React ancestors, independent of their DOM location.
Summarize the key difference between the DOM tree and React tree for a Portal in one sentence.
A Portal's content lives in a different place in the DOM tree but the same place in the React tree, so styling/layout follow the DOM target while data flow and events follow the React parent.
Which three advanced patterns are alternatives for sharing cross-cutting logic, and which is preferred in modern React?
Higher-Order Components, Render Props, and Custom Hooks. Custom Hooks are preferred in modern React because they reuse logic without extra wrapper components.
What this deck covers
The Advanced Concepts deck follows the ReactJS Advanced Concepts syllabus — 3 chapters and 9 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 16.7 cards per chapter.
Answers are written to be recallable, not just readable — averaging about 177 characters, which is long enough to carry the reasoning and short enough to say out loud.
A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.
Advanced Concepts flashcards FAQ
How many Advanced Concepts flashcards are in this ReactJS deck?
50 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.
Are these ReactJS flashcards free?
Yes. The preview here is free to read with no signup, and the full 50-card deck is free inside the Examius app.
What do the Advanced Concepts cards cover?
They follow the ReactJS Advanced Concepts syllabus — 3 chapters and 9 topics — so the questions track what is actually examinable.
How should I use these flashcards?
Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.