Filter by the role you are applying for, open a question, and practise explaining the answer out loud. Mark it practised when you can.
Why they ask this: Separates candidates who understand rendering performance from those who memoise everything by habit.
Answer
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
Why they ask this: Shows you understand the core of the framework and can write testable, loosely coupled code.
Answer
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.)
Dependency injection (DI) means a class receives the objects it needs (its dependencies) from outside, usually through the constructor, instead of creating them itself. This makes code easier to test and swap.
The service container is Laravel's tool for building objects and their dependencies. It uses reflection on type hints to auto-resolve concrete classes, so this works with no configuration:
class InvoiceController
{
public function __construct(private InvoiceService $invoices) {}
}For interfaces, you tell the container which implementation to use, usually in a service provider:
$this->app->bind(PaymentGateway::class, KhaltiGateway::class);
$this->app->singleton(ExchangeRates::class, fn () => new ExchangeRates(config('services.nrb.url')));Benefits:
$this->app->instance(PaymentGateway::class, new FakeGateway).