Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
When items.length is 0, the original expression can render 0. An explicit Boolean comparison prevents that output.
Question 26 of 60 · Lifting state up in component hierarchies · Medium
A SearchBox sibling controls the products shown by a ProductList. Where should the search query usually be stored?
Not quite. Try another option.
Answer: In their closest common parent
The common parent can pass the query and its updater to SearchBox and the filtered data or query to ProductList.
Question 27 of 60 · Defining component responsibility boundaries · Medium
A UserProfile component fetches data, handles routing, formats dates, and renders a large form. Which refactoring best improves responsibility boundaries?
Not quite. Try another option.
Answer: Split data logic and focused UI components
Separating data coordination from focused presentation and form components gives each unit a clearer responsibility and improves testability.
Question 28 of 60 · Styling approaches in React applications · Medium
Two components import CSS Modules that both define a .title class. What is the expected result?
Not quite. Try another option.
Answer: Each title receives a locally scoped class
CSS Modules generate scoped class names, so identical source class names in different modules do not normally collide.
Question 29 of 60 · Tailwind CSS fundamentals · Medium
Which Tailwind class list gives a button horizontal padding of 1rem and vertical padding of 0.5rem using the default spacing scale?
Not quite. Try another option.
Answer: px-4 py-2
px-4 applies left and right padding, while py-2 applies top and bottom padding.
Question 30 of 60 · Utility-first styling methodology · Medium
A button variant is currently built as `bg-${color}-600`. Production CSS sometimes omits the generated class. What is the best utility-first solution?
Not quite. Try another option.
Answer: Map variants to complete class strings
Tailwind detects complete class names in source files more reliably. A variant map such as { primary: 'bg-blue-600' } keeps utilities discoverable.
Question 31 of 60 · Responsive design using Tailwind breakpoints · Medium
A card should be full width by default, half width on medium screens, and one-third width on large screens. Which classes implement this?
Not quite. Try another option.
Answer: w-full md:w-1/2 lg:w-1/3
Tailwind is mobile-first: the unprefixed class applies initially, and md: and lg: override it at their respective minimum widths.
Question 32 of 60 · Reusable UI styling patterns · Medium
Several buttons share base Tailwind classes but differ by primary, danger, or secondary variants. Which approach is most maintainable?
Not quite. Try another option.
Answer: Select complete variant classes in one component
A reusable button can centralize base styles and map each variant to a known set of utility classes, reducing duplication and inconsistency.
Question 33 of 60 · Accessibility fundamentals · Medium
A form displays the text Email address next to an email input. Which implementation reliably associates the label with the field?
The button retains native interaction behavior, aria-label supplies its accessible name, and aria-hidden prevents duplicate announcement of the icon.
Question 41 of 60 · Functional components · Hard
A counter must increase by exactly 2 when incrementTwice is called, including when React batches state updates. Which implementation is correct?
JSX
function Counter() {
const [count, setCount] = useState(0);
// incrementTwice is defined here
}
Not quite. Try another option.
Answer: const incrementTwice = () => { setCount(c => c + 1); setCount(c => c + 1); };
Functional updater calls are applied sequentially to the latest queued state. Both updates therefore contribute, even when React batches them.
Question 42 of 60 · Props-driven component reusability · Hard
A reusable list must support unrelated item schemas, preserve item state during reordering, and allow callers to control rendering. Which prop API best satisfies these requirements?
getKey separates identity from schema, while renderItem delegates presentation. Stable domain keys also preserve the correct component instances during reordering.
Question 43 of 60 · Component composition patterns · Hard
A Dialog must own focus management and layout while allowing callers to provide arbitrary header, body, and footer content. Which design most directly applies composition without making Dialog depend on application-specific data?
Named element props and children act as composition slots. The dialog retains structural and behavioral responsibility without encoding domain-specific content.
Question 44 of 60 · Reusable component abstractions · Hard
Several visually unrelated components require the same disclosure state, Escape-key behavior, and ARIA prop generation, but they must produce different markup. Which abstraction is most appropriate?
Not quite. Try another option.
Answer: A custom hook returning state, actions, and prop-getter functions
A custom hook can reuse stateful behavior without prescribing markup. Prop getters can consistently supply handlers and accessibility attributes to each component.
Question 45 of 60 · Conditional rendering strategies · Hard
Given {unreadCount && <Badge>{unreadCount}</Badge>}, users see an unwanted 0 when unreadCount is zero. Which replacement hides the badge without rendering the numeric value?
The ternary explicitly returns null for zero. With &&, React renders the left operand when that operand is the renderable number 0.
Question 46 of 60 · Lifting state up in component hierarchies · Hard
Two sibling temperature inputs must remain synchronized, but the currently edited input must temporarily accept incomplete text such as - or 1.. What should their nearest common parent store?
Not quite. Try another option.
Answer: The raw input string and the scale of the most recently edited input
The parent keeps one authoritative raw value and its scale. The sibling value can be derived only when parsing succeeds, preserving transient but valid editing states.
Question 47 of 60 · Defining component responsibility boundaries · Hard
A page fetches orders, a list lays them out, and each row exposes a retry action. The retry requires page-level authentication and cache invalidation. Which boundary best separates responsibilities?
Not quite. Try another option.
Answer: The page owns fetching and retry orchestration; rows receive order data and callbacks
The page coordinates application-level data concerns, while list and row components focus on presentation and emit user intent through callbacks.
Question 48 of 60 · Styling approaches in React applications · Hard
A CSS Module defines .root, .primary, and .danger. The component receives variant as either "primary" or "danger". Which expression correctly combines the scoped classes?
Not quite. Try another option.
Answer: className={{styles[variant]}}
CSS Module imports map local class names to generated identifiers. Bracket notation retrieves the generated class corresponding to the runtime variant.
Question 49 of 60 · Tailwind CSS fundamentals · Hard
A production build omits colors generated by className={bg-${color}-600}, although the classes appear during development. Assuming color comes from a fixed supported set, what is the most robust correction?
Not quite. Try another option.
Answer: Map each supported color to a complete literal class such as bg-red-600
Tailwind source detection recognizes complete class tokens, not arbitrary runtime interpolation. A static variant map makes every supported class discoverable.
Question 50 of 60 · Utility-first styling methodology · Hard
An application repeats a long button class list and must support consistent variants, disabled behavior, and loading indicators. Which refactoring best preserves utility-first styling while centralizing the design contract?
Not quite. Try another option.
Answer: Create a Button component with static utility strings selected by typed variant props
A reusable component centralizes behavior and sanctioned variants while retaining explicit, statically detectable utility classes.
Question 51 of 60 · Responsive design using Tailwind breakpoints · Hard
Using Tailwind's default mobile-first breakpoints, when is an element with hidden md:flex lg:hidden xl:flex displayed?
Not quite. Try another option.
Answer: From md to below lg, and again at xl and above
Responsive variants apply at their minimum widths. md:flex reveals the element, lg:hidden hides it again, and xl:flex restores it.
Question 52 of 60 · Reusable UI styling patterns · Hard
A reusable component uses className={clsx("px-4 py-2", className)}. A caller passes "px-2", but the intended override is unreliable because conflicting Tailwind utilities are both present. Which solution best expresses override semantics?
Not quite. Try another option.
Answer: Merge the result with a Tailwind-aware conflict resolver such as twMerge
clsx conditionally concatenates tokens but does not remove semantic conflicts. A Tailwind-aware merger can retain the intended winning utility, such as px-2.
Question 53 of 60 · Accessibility fundamentals · Hard
A validation error is displayed immediately after an email field. Which markup gives the input an accessible name, exposes invalid state, and associates the error message with the field?
The label names the input, aria-invalid communicates its state, and aria-describedby adds the identified error text to its accessible description.
Question 54 of 60 · Semantic HTML practices in React · Hard
A card navigates to an article when its main area is activated, but it also contains an independent Save button. Which structure avoids invalid nested interactive controls while preserving both actions?
Not quite. Try another option.
Answer: Use an <article> with a heading link expanded by CSS and a sibling <button> layered above it
The link and button remain sibling interactive elements with distinct semantics. CSS can enlarge the link's hit area without nesting one control inside another.
Question 55 of 60 · Component composition patterns · Hard
The following component unexpectedly resets Editor state whenever framed changes:
Keeping the same element hierarchy and component position preserves React's state identity. Changing only the wrapper's class avoids remounting Editor.
Question 56 of 60 · Conditional rendering strategies · Hard
While remaining in edit mode, the application may switch directly from record A to record B. The form initializes local state from record, but currently retains A's edits. Which rendering strategy intentionally resets the form for B?
Changing the key changes the component's identity, causing React to remount the form and initialize fresh local state for the new record.
Question 57 of 60 · Lifting state up in component hierarchies · Hard
A parent fetches an updated array of products while two children share the current selection. Product objects may be replaced even when their IDs remain stable. What should the parent store as the authoritative selection?
Not quite. Try another option.
Answer: The selected product ID, deriving the current product from the latest array
An ID is stable domain identity. Deriving the object from current data avoids stale object references and remains correct when items are replaced or reordered.
Question 58 of 60 · Styling approaches in React applications · Hard
A server-rendered component chooses "desktop" or "mobile" classes by reading window.innerWidth during render. The difference is purely visual. Which approach best avoids hydration mismatches and resize synchronization code?
Not quite. Try another option.
Answer: Render one structure and express the layout change with CSS media queries
CSS media queries handle visual responsiveness without making server and client markup depend on different viewport information.
Question 59 of 60 · Accessibility fundamentals · Hard
A custom horizontal tab interface uses elements with role="tab". Which interaction and ARIA model most closely follows the standard tabs pattern?
Not quite. Try another option.
Answer: Use roving tabIndex, arrow-key navigation, aria-selected, and aria-controls references
Tabs conventionally expose one tab in the page tab order, support arrow-key movement, identify selection, and reference their associated tab panels.
The parent passes an onSave callback that closes over the current draft. Why can clicking the button save an older draft when the label is unchanged?
Not quite. Try another option.
Answer: The comparator ignores onSave, so React may retain a render containing an older callback
A custom comparator must account for every prop that affects behavior. Ignoring onSave can preserve the previous closure; comparing it or removing the comparator fixes the issue.
That's unit 2
Answer a few questions and your score shows up here.
Nearly through. Did unit 2 of INT252 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 2 of INT252 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.