Why they ask this: Hooks are how modern React is written; breaking the rules causes hard-to-find bugs.
Answer
Hooks are functions that let function components use React features: useState (state), useEffect (side effects), useContext, useRef, useMemo, useCallback, and your own custom hooks (useSomething).
Rules of hooks:
function Profile({ userId }) {
const [user, setUser] = useState(null); // top level: OK
Why they ask this: Many companies are in Kathmandu Valley, while others are remote or hybrid; HR needs to know whether the arrangement works for you.
How to answer
Sample answer · STAR
Why they ask this: Most React bugs (infinite loops, stale data, memory leaks) come from misusing useEffect.
Answer
Why they ask this: Wrong keys cause subtle UI bugs, so this checks practical experience.
Answer
Why they ask this: Forms are in every app; this shows how you handle user input and validation.
Answer
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: Most users in Nepal browse on mobile phones, so responsive design is a must-have skill.
Answer
Why they ask this: Middleware is how cross-cutting concerns like auth are handled; it shows you understand the request lifecycle.
Answer
The eslint-plugin-react-hooks lint rules catch most mistakes.
Be honest and specific about what you can do: relocating to Kathmandu, Lalitpur or Pokhara, working on-site or hybrid, or remotely with a reliable internet connection and power backup. If you have constraints, explain them briefly and offer a solution.
For remote roles, show that you can work independently: a quiet workspace, a backup internet connection (or a mobile data plan), and clear communication habits.
Avoid: saying yes to something you cannot actually do. It will cause problems after you join.
"Yes. I'm currently in Chitwan, and I'm ready to move to Kathmandu within two weeks of an offer. I have relatives in Lalitpur where I can stay at first.
I'm also comfortable with a hybrid setup. During my remote internship last year I worked with a fibre connection plus a mobile data backup, posted daily written updates on Slack, and joined every stand-up on time, so I know how to stay visible and productive when working from home."
useEffect(effect, deps) runs effect after render:
[]: runs once after the first render (mount).[a, b]: runs after the first render and again whenever a or b changes (compared with Object.is).The function you return is the cleanup. It runs before the effect runs again and when the component unmounts. Use it to remove listeners, clear timers and cancel requests.
useEffect(() => {
const controller = new AbortController();
fetch(`/api/jobs?q=${query}`, { signal: controller.signal })
.then((r) => r.json())
.then(setJobs)
.catch(() => {});
return () => controller.abort(); // cancel the old request when query changes
}, [query]);Include every value from the component that the effect uses in the array. Missing dependencies cause stale values.
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} />
))}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)} />
// Uncontrolled
const inputRef = useRef(null);
<input ref={inputRef} defaultValue="" />
// later: inputRef.current.valueChoose 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.
<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); }
}Middleware is a layer that every matching HTTP request passes through before it reaches the controller, and the response passes back through after. Each middleware can let the request continue ($next($request)), change it, or stop it early.
Common uses:
auth / auth:sanctum reject guests./admin.throttle:60,1.class EnsureUserIsAdmin
{
public function handle(Request $request, Closure $next): Response
{
if (! $request->user()?->is_admin) {
abort(403);
}
return $next($request);
}
}
Route::middleware(['auth', EnsureUserIsAdmin::class])->group(function () {
Route::get('/admin', AdminDashboardController::class);
});