JS Guide
HomeQuestionsSearchResources
Search

Built for developers preparing for JavaScript, React & TypeScript interviews.

ResourcesQuestionsSupport
HomeQuestionsSearchProgress
HomeQuestionsreact

react

React components, hooks, patterns, and best practices

Your Progress

0 of 8 completed

0%

8 Questions

mid Level
1
Explain the useState and useEffect hooks and their common patterns.
mid
hooks
useState manages local state in functional components, returning a value and setter function. useEffect handles side effects (data fetching, subscriptions, DOM manipulation) and runs after render. The dependency array controls when effects re-run.
2
What is React Context and when should you use it?
mid
context
Context provides a way to pass data through the component tree without prop drilling. Use it for global data like themes, authentication, or locale. For frequently changing data or complex state logic, consider state management libraries instead.
3
What are custom hooks and how do you create them?
mid
hooks
Custom hooks are JavaScript functions starting with 'use' that encapsulate reusable stateful logic. They can use other hooks and share logic between components without duplicating code or adding components to the tree.
4
What is useRef and when should you use it?
mid
hooks
useRef creates a mutable reference that persists across renders without causing re-renders when changed. Use it for accessing DOM elements, storing mutable values that don't need to trigger updates, and keeping references to timers or previous values.
5
What is the difference between controlled and uncontrolled components in React forms?
mid
forms
Controlled components have their form data managed by React state - the input value is always driven by state. Uncontrolled components let the DOM handle form data using refs to access values when needed. Controlled components are recommended for most cases.
6
How does React Router work and what are its key features?
mid
routing
React Router provides client-side routing for React applications, enabling navigation without page reloads. It uses components like BrowserRouter, Routes, Route, and Link, with hooks like useNavigate and useParams for programmatic navigation and accessing route parameters.
7
How do you ensure accessibility (a11y) in React applications?
mid
accessibility
Ensure accessibility by using semantic HTML elements, proper ARIA attributes (aria-label, role), managing focus for dynamic content, supporting keyboard navigation, using htmlFor with labels, and testing with tools like eslint-plugin-jsx-a11y and screen readers.
8
How do you integrate UI component libraries with React and when should you use them?
mid
libraries
UI libraries like Material-UI, Chakra UI, and Radix provide pre-built, accessible components. Integrate them by installing the package, wrapping your app with a ThemeProvider, and importing components. Use them for rapid development and consistent design; build custom when you need unique designs or minimal bundle size.