React Router, Context versus Redux and Zustand, data fetching with React Query, performance optimization and React Testing Library.
34 cards · basic cards · AI-written, checked twice. Edit anything.
- What is React Router used for?
Show answer
Declarative routing library for single-page applications, enabling navigation between components without full page reloads.
- What does BrowserRouter do?
Show answer
Provides the routing context for a React app by syncing the UI to the URL using the History API.
- What is a dynamic route segment?
Show answer
A URL path part that captures variable values, like /users/:id where :id is the dynamic part.
- How do you get URL parameters in React Router v6?
Show answer
Use the useParams hook to access named parameters from the current route.
- What replaces the Switch component in React Router v6?
Show answer
The Routes component, which matches the first route that corresponds to the path.
- What does useNavigate do?
Show answer
Returns a function to programmatically navigate to a different route.
- What is nested routing in React Router?
Show answer
Organizing routes as a tree where child routes inherit their parent's URL path.
- How does Link differ from an HTML a tag?
Show answer
Link navigates without a full page reload and preserves component state; a tag causes a full page reload.
- When is Context API preferred over Redux?
Show answer
For simple state that does not need middleware, dev tools, time travel, or complex state logic.
- What is the main issue with Context API at scale?
Show answer
Frequent re-renders when context value changes, as all consuming components re-render regardless of whether they use only part of the value.
- What is the Redux store?
Show answer
A single object that holds the entire application state and provides methods to access and update it.
- What is a Redux action?
Show answer
A plain object with a type property describing what happened, optionally containing additional data.
- What is a Redux reducer?
Show answer
A pure function that takes the current state and an action, returning the new state.
- How does Zustand differ from Redux?
Show answer
Zustand is simpler and lighter weight with a hooks-based API; Redux is more structured with middleware and dev tools.
- What is Redux middleware used for?
Show answer
Intercepting actions between dispatch and the reducer to handle async operations, logging, or side effects.