React Advanced Flashcards
(40 cards)
What is server-side rendering (SSR) in React?
Rendering React components on the server and sending HTML to the client for faster load and SEO.
What is hydration in SSR?
The process where React attaches event listeners to server-rendered HTML on the client.
What are the main differences between SSR and client-side rendering?
SSR renders HTML on the server and improves SEO/load time; CSR renders in the browser after JS loads.
How does Next.js enhance React applications?
It provides SSR, file-based routing, API routes, and static generation for production-ready apps.
What is static site generation (SSG)?
A method to pre-render pages at build time for performance and scalability.
What are React Suspense and Concurrent Mode?
Suspense allows lazy loading of components; Concurrent Mode enables interruptible rendering for better responsiveness.
What is the difference between useTransition and useDeferredValue?
useTransition lets you mark updates as non-urgent; useDeferredValue postpones a value update until more urgent tasks finish.
What is React Fiber?
A complete rewrite of React’s core algorithm to enable concurrency and incremental rendering.
How do you handle authentication in a React app?
Using tokens (JWT), context or state for user session, and protected routes via React Router.
How does context API compare to Redux?
Context is simpler for small global states; Redux offers more control, middleware, and dev tools.
What is Redux Toolkit?
A standardized, efficient way to write Redux logic with less boilerplate.
What is the purpose of middleware in Redux?
To intercept and handle actions for tasks like async calls (e.g., Redux Thunk, Redux Saga).
What is the React Profiler API?
A tool to measure the performance of React components during render cycles.
How can you reduce bundle size in React apps?
By code splitting, tree shaking, using React.lazy, and avoiding unnecessary libraries.
What is tree shaking?
A process during build that removes unused code from bundles.
What are render props?
A technique for sharing code between components using a function prop that returns JSX.
What is a higher-order component (HOC)?
A function that takes a component and returns a new component with enhanced behavior.
What are the downsides of HOCs?
They can lead to wrapper hell, harder debugging, and prop collisions.
What is useImperativeHandle?
A hook to customize the instance value exposed when using React.forwardRef.
What is React.forwardRef?
A function to pass refs from parent to child components.
What is the difference between controlled and uncontrolled components?
Controlled are managed by React state; uncontrolled store state in the DOM.
How do you test React components?
Using Jest and React Testing Library to write unit and integration tests.
What is shallow rendering in testing?
Rendering only the component under test without its children to isolate behavior.
What is the role of React Testing Library?
To test components from the user’s perspective, focusing on accessibility and actual DOM output.