$ show sudheerj/reactjs-interview-questions
This repository is a comprehensive collection of React interview questions and coding exercises, designed as an educational resource for developers preparing for React interviews. It contains over a dozen standalone React projects built with modern tooling (Vite, TypeScript, React 19), each demonstrating a specific UI pattern or hook implementation. The codebase is well-organized into three main sections: a coding-exercise app with a registry pattern for interactive problem-solving, a coding-hooks library of reusable custom hooks (useDebounce, useFetch, useLocalStorage, etc.), and a set of coding-projects (accordion, autocomplete, carousel, data table, infinite scroll, modal, nested comments, shopping cart, star rating, theme switcher, todo, tree view). The projects are cleanly implemented with TypeScript, proper state management, and accessibility considerations. While primarily educational, the custom hooks and several UI components are production-quality and directly reusable in other projects.
The LLM identified 5 files worth highlighting for reuse:
A generic useDebounce hook that delays updating a value until a specified delay has elapsed since the last change. It uses useEffect with setTimeout and cleanup, and is fully typed with TypeScript generics. This hook is self-contained, has no internal dependencies, and can be extracted into any React project to debounce search inputs, API calls, or any rapidly changing value.
A simple useFetch hook that takes a URL and returns { data, loading } with proper TypeScript generics. It uses useEffect to fetch data on mount and when the URL changes. The hook is minimal, self-contained, and can be easily extended with error handling or abort controllers. It demonstrates a clean pattern for data fetching in functional components.
A useLocalStorage hook that syncs state with localStorage. It initializes state from localStorage (with JSON parsing) and persists changes via useEffect. The hook is generic, handles edge cases (missing key, initial value), and returns a tuple like useState. It is fully self-contained and reusable for any React app needing persistent state.
A reusable Modal component with overlay, close on Escape key, close on overlay click, and proper ARIA attributes. It uses a portal-like pattern (renders in a fixed overlay) and accepts title, children, and onClose. The component is self-contained with its own CSS, handles cleanup of event listeners, and can be extracted into any React project for dialog needs.
A StarRating component with hover and click interactions, customizable max rating, and a display of the current rating. It includes a comprehensive test suite (StarRating.test.tsx) using Jest and Testing Library, covering rendering, selection, and hover highlighting. The component is self-contained, well-typed, and demonstrates a pattern for interactive rating widgets.