Why they ask this: Wrong keys cause subtle UI bugs, so this checks practical experience.
Answer
A key gives each list item a stable identity, so React can tell which items were added, removed or reordered between renders and keep the right state and DOM node for each one.
{todos.map((todo) => (
<TodoItem key={todo.id} todo={todo} />
))}Why they ask this: Forms are in every app; this shows how you handle user input and validation.
Answer
value comes from state and every change goes through onChange.ref or from the form data on submit.// Controlled
const [email, setEmail] = useState('');
<input value={email} onChange={(e) => setEmail(e.target.value)} />
Why they ask this: The most basic React concept; a weak answer is a red flag for any React role.
Answer
Why they ask this: Separates candidates who understand rendering performance from those who memoise everything by habit.
Answer
Why they ask this: Shows you care about accessibility and SEO, not only how a page looks.
Answer
Why they ask this: Layout bugs often come from misunderstanding widths, padding and borders.
Answer
Why they ask this: Checks you can choose the right layout tool instead of fighting CSS.
Answer
Why they ask this: Explains "why is my style not applying?" problems that every frontend developer hits.
Answer
Why they ask this: Positioning is needed for dropdowns, modals and sticky headers.
Answer
Why they ask this: Most users in Nepal browse on mobile phones, so responsive design is a must-have skill.
Answer
Why they ask this: Accessibility is increasingly expected; it shows care for all users and code quality.
Answer
Why they ask this: Every developer calls or builds APIs; correct method use is a basic expectation.
Answer
Choose controlled inputs for instant validation, formatting or conditional UI. Uncontrolled inputs are simpler for basic forms and file inputs (<input type="file"> is always uncontrolled). Form libraries such as React Hook Form mostly use uncontrolled inputs for performance.
| Props | State | |
|---|---|---|
| Owned by | the parent | the component itself |
| Changeable by the component? | No, read-only | Yes, through the setter (setX) |
| Purpose | configure a component and pass data down | data that changes over time |
function Counter({ step }) { // step is a prop
const [count, setCount] = useState(0); // count is state
return <button onClick={() => setCount((c) => c + step)}>{count}</button>;
}Changing either one re-renders the component. When two siblings need the same data, lift the state up to their common parent and pass it down as props.
useMemo(fn, deps) caches a computed value until deps change.useCallback(fn, deps) caches a function reference until deps change. It is the same as useMemo(() => fn, deps).Use them when:
React.memo, and a new reference every render would defeat it.useEffect) and a new reference would re-run it every render.const visibleJobs = useMemo(
() => jobs.filter((j) => j.title.toLowerCase().includes(query.toLowerCase())),
[jobs, query],
);
const handleSelect = useCallback((id) => setSelected(id), []);Skip them for cheap calculations and for handlers passed to plain DOM elements. Memoisation itself costs memory and comparisons, so measure with the React DevTools Profiler before you optimise. (React Compiler can add this memoisation automatically in projects that use it.)
Semantic HTML uses elements that describe their meaning, not only their appearance: <header>, <nav>, <main>, <article>, <section>, <aside>, <footer>, <button>, <label>, and headings <h1>–<h6> in order.
Why it matters:
<button> is keyboard-focusable and clickable with Enter or Space by default; a clickable <div> is not.<main>
<article>
<h1>Frontend Developer at Kathmandu Tech</h1>
<p>...</p>
<button type="button">Apply now</button>
</article>
</main>Every element is a box made of four layers, from inside out: content → padding → border → margin.
box-sizing: content-box, width sets only the content. Padding and border are added on top, so width: 200px; padding: 20px; border: 1px renders 242px wide.box-sizing: border-box, width includes padding and border, so the element stays 200px wide. This is far easier to reason about.*, *::before, *::after {
box-sizing: border-box;
}Margins are outside the box and can collapse: vertical margins of adjacent block elements combine into the larger of the two instead of adding up.
/* Flexbox: navbar */
.nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
/* Grid: responsive cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }They work well together, for example a Grid page layout with Flexbox inside each card.
When several rules target the same element, the browser picks the one with the highest specificity. If specificity is equal, the rule that appears later wins.
Specificity is compared as (IDs, classes/attributes/pseudo-classes, elements/pseudo-elements):
| Selector | Specificity |
|---|---|
p | (0, 0, 1) |
.card p | (0, 1, 1) |
#main .card p | (1, 1, 1) |
inline style="" | beats any selector |
!important | overrides normal declarations; avoid it |
:where() adds zero specificity, while :is() and :not() take the specificity of their most specific argument.
Keep specificity low and flat (for example single classes with a BEM-style or utility approach) so styles stay easy to override.
static (default): normal document flow. top/left have no effect.relative: stays in the flow, but can be nudged with top/left. It also becomes the containing block for absolutely positioned children.absolute: removed from the flow and positioned relative to the nearest positioned ancestor (any value other than static), or the initial containing block if there is none.fixed: removed from the flow and positioned relative to the viewport, so it stays put while scrolling. Note that a transform on an ancestor changes this.sticky: acts like relative until a scroll threshold (such as top: 0) is reached, then sticks within its parent..dropdown-wrapper { position: relative; }
.dropdown-menu { position: absolute; top: 100%; left: 0; }
.site-header { position: sticky; top: 0; }<meta name="viewport" content="width=device-width, initial-scale=1">.min-width media queries for larger ones.fr and minmax()) and relative units (%, rem, vw) instead of fixed pixel widths.img { max-width: 100%; height: auto; }, and use srcset for different image sizes..grid { display: grid; gap: 1rem; }
@media (min-width: 768px) {
.grid { grid-template-columns: repeat(2, 1fr); }
}<button>, <nav>, <main>, headings in order) before reaching for ARIA.alt text (alt="" for decorative images).<label> (for/id, or wrap the input).:focus-visible style.aria-expanded on a menu toggle or aria-live for status messages.Check your work with Lighthouse or axe DevTools and by navigating with only the keyboard.
| Method | Use | Safe | Idempotent |
|---|---|---|---|
GET | read a resource | yes | yes |
POST | create a resource or trigger an action | no | no |
PUT | replace a resource completely | no | yes |
PATCH | update part of a resource | no | not guaranteed |
DELETE | remove a resource | no | yes |
POST /orders calls can create two orders, while PUT /users/5 with the same body twice gives the same result.This matters for retries: clients and proxies can safely retry idempotent requests after a network error. For payments, use an idempotency key to make POST safe to retry.