100 curated React questions covering TypeScript prop narrowing, useActionState, useOptimistic, RSCs, state libraries (Zustand/RTK), virtualization, and enterprise performance optimizations.
Preview Mode Active · 5 Free Sample Questions
Review verified answers and code patterns below. The remaining 94 questions in this codex are unlocked with the Interview Pass or Full Access.
Plain object typing ({ href?: string; onClick?: () => void }) allows both, neither, or either - TypeScript won't catch a caller passing both. To make combinations mutually exclusive, model props as a discriminated union: define two separate shapes and union them, e.g. type LinkProps = { as: 'link'; href: string; onClick?: never } | { as: 'button'; onClick: () => void; href?: never }, so a discriminant field (or the mere presence/absence of a required field) lets TypeScript narrow which variant applies and reject invalid combinations at the call site. A lighter-weight version without an explicit discriminant uses Exclude-style 'never' props on the sibling variant ({ href: string; onClick?: never } | { href?: never; onClick: () => void }) so providing both produces a type error. The general principle senior candidates are expected to articulate: use the type system to make invalid states unrepresentable, rather than relying on runtime checks or comments.
You have reached the end of the 5 free preview questions. Get unrestricted lifetime access to all 99 questions, model solutions, architectural blueprints, and complete DSA codex.
One-time settlement · Lifetime access · Zero recurring bills