⚛️ Top 150 React Interview Questions – 144/150 📌 Topic: 🔄 TanStack Query ━━━━━━━━━━━━━━━━━━━━━━ 🔹 WHAT is it? TanStack Query (formerly React Query) is an asynchronous state management library designed specifically for Server State. It automates: • Data fetching • Caching • Background synchronization • Loading & error handling It replaces complex useEffect + useState logic with a single powerful hook. Client State ≠ Server State TanStack Query is built for Server State. ━━━━━━━━━━━━━━━━━━━━━━ 🔹 WHY use TanStack Query? ⚡ Auto-Caching API responses are cached and reused instantly. 🔁 Stale-While-Revalidate Shows cached data immediately while fetching fresh data in the background. 🧹 Zero Boilerplate No manual loading, error, or refetch logic. 📡 Auto Refetching Refetches on window focus, reconnect, or interval — automatically. 🚀 Performance Boost Prevents unnecessary network calls. It makes data fetching declarative. ━━━━━━━━━━━━━━━━━━━━━━ 🔹 HOW to use it? Use the useQuery hook. import { useQuery } from '@tanstack/react-query'; const { data, isLoading, error } = useQuery({ queryKey: ['user'], queryFn: () => fetch('/api/user').then(res => res.json()), }); ✅ Rendering if (isLoading) return <p>Loading...</p>; if (error) return <p>Error occurred</p>; return <h1>{data.name}</h1>; ✔ Automatic caching ✔ Background refetch ✔ Clean lifecycle handling No manual useEffect. ━━━━━━━━━━━━━━━━━━━━━━ 🔹 WHERE to use it? 📊 Dashboards Sync multiple widgets without refreshing the page. 📄 Pagination & Infinite Scroll Handles page caching automatically. 📶 Offline Support Shows cached data when connection drops. 🛒 E-commerce Cart, product lists, stock updates. Enterprise apps benefit massively. ━━━━━━━━━━━━━━━━━━━━━━ 📝 SUMMARY Using useEffect is like Manually Fetching Water from a Well 🪣 You go every time, pull the bucket, handle spills yourself. TanStack Query is a Smart Water Purifier 💧 It stores clean water (Cache), refills automatically, and handles everything in the background. ━━━━━━━━━━━━━━━━━━━━━━ 👇 Comment “React” if this series is helping you 🔁 Share with someone tired of writing manual useEffect logic #ReactJS #TanStackQuery #ServerState #WebPerformance #FrontendArchitecture #Top150ReactQuestions #LearningInPublic #Developers ━━━━━━━━━━━━━━━━━━━━━━
TanStack Query: Simplify Server State Management with Auto-Caching
More Relevant Posts
-
Struggling to crack your next frontend interview? You’re not alone. With ReactJS being one of the most in-demand skills, mastering the right concepts can give you a serious edge. At InterviewBuzz, we’ve simplified your journey with expert-curated resources to help you prepare smarter, not harder. 💡 What you’ll learn: ✔ Core React concepts (Components, JSX, Props & State) ✔ Advanced topics like Hooks, Context API & Virtual DOM ✔ Real-world interview questions & answers ✔ Performance optimization techniques ✔ Latest React trends (React 18+ features) React is widely used for building fast, scalable, and interactive user interfaces, making it a must-have skill for modern developers. 🔥 Whether you're a beginner or an experienced developer, this guide will help you boost confidence and crack interviews faster. 👉 Start your preparation now: https://lnkd.in/dVAPYxAk #ReactJS #FrontendDevelopment #WebDevelopment #JavaScript #CodingInterview #InterviewPreparation #TechCareers #Developers #ReactInterview #LearnToCode #Programming #CareerGrowth
To view or add a comment, sign in
-
After Several Product-Based Backend Interviews, These 30 System Design Questions Appeared Again and Again Over the last few months, I went through multiple backend interviews with product-based companies. One thing became very clear. Companies are not just evaluating coding ability. They want to see how you think about systems at scale. Sharing some system design problems that appeared repeatedly during interviews. Hopefully this helps anyone preparing for backend/system design roles. 1️⃣ Implement an LRU Cache with TTL support 2️⃣ Design a Rate Limiter 3️⃣ Design a Request Counter system (per user/IP) 4️⃣ Design a URL Shortener (like bit.ly) 5️⃣ Design a Distributed Cache system 6️⃣ Design a Notification system (email / push / SMS) 7️⃣ Design a Real-time Chat system 8️⃣ Design a Log aggregation system 9️⃣ Design a Distributed task queue 🔟 Design an API Gateway 1️⃣1️⃣ Design a Message Queue system 1️⃣2️⃣ Design a Distributed Lock service 1️⃣3️⃣ Design a Search Autocomplete system 1️⃣4️⃣ Design a Real-time analytics pipeline 1️⃣5️⃣ Design a Distributed ID generator (Snowflake) 1️⃣6️⃣ Design a Payment processing system 1️⃣7️⃣ Design a Feature flag / configuration service 1️⃣8️⃣ Design a Metrics & monitoring system 1️⃣9️⃣ Design a Large file upload service 2️⃣0️⃣ Design a system capable of handling 10K+ requests per second 2️⃣1️⃣ Design a News Feed system 2️⃣2️⃣ Design a Session management system 2️⃣3️⃣ Design a Distributed logging system 2️⃣4️⃣ Design a Leaderboard system 2️⃣5️⃣ Design a Recommendation system 2️⃣6️⃣ Design a Web crawler 2️⃣7️⃣ Design a Distributed search service 2️⃣8️⃣ Design a stream processing pipeline 2️⃣9️⃣ Design a real-time event processing system 3️⃣0️⃣ Design a cache invalidation strategy These questions usually evaluate your understanding of: • scalability • caching strategies • distributed systems • data partitioning • fault tolerance • trade-offs in architecture Understanding how systems behave under scale and failure often matters more than just knowing frameworks. 💬 Which system design question has appeared most frequently in your interviews? #SystemDesign #BackendEngineering #Microservices #DistributedSystems #SoftwareArchitecture #java #springboot #InterviewPreparation #microservices
To view or add a comment, sign in
-
In System Design interviews interviewer might ask about RESTful Pagination Strategies. If you're preparing for backend or system design interviews, this topic is gold. 👇 There are two common RESTful Pagination Strategies: 1️⃣ Offset-Based Pagination 2️⃣ Cursor-Based Pagination Let’s break them down properly. 🔹 1️⃣ Offset-Based Pagination 👉 Definition: Client requests data using offset and limit. 👉 How it works: Database skips N rows and returns the next M rows. ✅ Example API GET /posts?offset=20&limit=10 ✅ SQL Query SELECT * FROM posts ORDER BY created_at DESC LIMIT 10 OFFSET 20; 👍 Use Cases ✋ Admin dashboards ✋ Reporting tools ✋ Small datasets ✋ When page numbers (Page 1, 2, 3…) are required ❌ Disadvantages ✋ Performance degrades with large offsets ✋ DB scans skipped rows ✋ Inconsistent results when new rows are inserted 🔹 2️⃣ Cursor-Based Pagination 👉 Definition: Instead of skipping rows, it fetches records after a specific reference (cursor). Cursor is usually: • ID • Timestamp (created_at) • Any indexed unique field ✅ Example API GET /posts?cursor=2025-01-01T10:00:00&limit=10 ✅ SQL Query SELECT * FROM posts WHERE id > 'cursor' ORDER BY created_at DESC LIMIT 10; 👍 Use Cases ✋ Infinite scroll feeds ✋ High-traffic APIs ✋ Large datasets ✋ Real-time applications ❌ Disadvantages ✋ Cannot jump directly to page 5 ✋ Slightly more complex logic ✋ Requires stable sorting column 🔥 Real-World Example 👉 Twitter moved from offset-based pagination to cursor-based pagination Why? ✔ Reduced DB query latency ✔ Improved infinite scroll performance ✔ Better scalability under heavy traffic That’s real system design thinking. 💻 Spring Boot Example – Cursor-Based Pagination (Using PageRequest.of() internally — builder-style configuration pattern) REST Controller (Cursor-Based) @RestController @RequestMapping("/posts") public class PostController { @Autowired private PostRepository postRepository; @GetMapping public Page<Post> getPosts( @RequestParam(required = false) LocalDateTime cursor, @RequestParam(defaultValue = "10") int size) { Pageable pageable = PageRequest .of(0, size, Sort.by("createdAt").descending()); if (cursor == null) { return postRepository.findAll(pageable); } return postRepository.findByCreatedAtLessThan(cursor, pageable); } } 🧠 Interview-Ready Answer If interviewer asks: ❓ “Which pagination strategy would you use for large-scale systems?” Answer like this: For large datasets and infinite scroll systems, I prefer cursor-based pagination because it avoids high-offset scans and provides consistent performance. That’s a senior backend answer. 👌 Pagination is not just a UI feature. It’s a scalability decision. Which strategy are you using in your project right now? 👇 #SystemDesign #SpringBoot #BackendDevelopment #RESTAPI #Scalability #Microservices #TechInterview #java #developer
To view or add a comment, sign in
-
Day 6: State vs Props (The Real Data Flow in React) React Interview Series | Day 6 One of the most common interview questions (especially for Junior & Mid-level devs): https://lnkd.in/gnxVZrXm 👉 “What’s the difference between State and Props?” Most people answer: “State is internal, Props are external.” ✔️ Correct… ❌ But not impressive. Let’s break it down in a way interviewers actually like 👇 💡 The Real Talk: Think of a React component like a function: 👉 Props = Function Arguments Passed from parent → child Read-only (you CANNOT modify them) Used to display or configure behavior 👉 State = Internal Variables Declared inside the component Fully controlled by the component Can change over time using useState 🔥 The Golden Rule: 👉 If data needs to change → use State 👉 If data just needs to be displayed → use Props 🧠 The “Senior-Level” Insight: Both Props and State trigger re-renders. But the real difference is: 👉 Who owns the data (source of truth)? Props → Controlled by parent State → Controlled by the component itself This is the foundation of one-way data flow in React. 🚀 Why This Matters in Interviews: Interviewers aren’t just testing definitions… They want to see if you understand: Data ownership Component responsibility Clean architecture thinking 💬 Let’s Discuss: When you first learned React… 👉 What confused you more: State updates or Props flow? Drop your thoughts 👇 Let’s help each other grow. #ReactJS #FrontendDevelopment #WebDevelopment #CodingInterviews #JavaScript #LearnToCode #30DaysOfCode
To view or add a comment, sign in
-
-
html-storage-api-interview-q Interview Trap: "Oh, the Storage API? It's just like cookies, but bigger." 🚫 If you said that in a 2026 interview, you just failed the role. Cookies were designed for server communication, not client-side persistence. The `Web Storage API` is the backbone of modern, app-like web experiences. Here's the Senior-level breakdown: 1️⃣ **The Core Function**: It provides a simple `key-value` store (`localStorage` & `sessionStorage`) that persists data directly in the browser, eliminating the need for constant server round-trips. This is non-negotiable for `offline-first` `PWA` architectures. 2️⃣ **The Nuance**: - `localStorage`: Data persists across sessions. Perfect for `user preferences` or `theme` settings. - `sessionStorage`: Data lives only for the tab duration. Ideal for `temporary form data` or `cart` states. 3️⃣ **The Security Trap**: Storing `JWT` tokens in `localStorage` is a massive `XSS` vulnerability. Always use `HttpOnly` cookies for sensitive auth data. The browser handles the rest. 4️⃣ **The 2026 Reality**: While `Web Storage` is great for simple strings, complex structured data requires `IndexedDB`. For assets, the `Cache API` is king. A true senior dev knows when to use which. Found this useful? Follow for more such interview questions and save post for your next prep session! #HTML,#WebDev,#Interviews,#CodingTips,#Frontend
To view or add a comment, sign in
-
-
⚛️ Top 150 React Interview Questions – 147/150 📌 Topic: 🛑 Stale Closures in React ━━━━━━━━━━━━━━━━━━━━━━ 🔹 WHAT is it? A Stale Closure happens when a function captures a variable from an old render and keeps using that outdated value. In React: Every render creates a new scope. If a function is created once and never updated, it keeps referencing the old state. Closure = Snapshot of variables at creation time. If not refreshed → it becomes stale. ━━━━━━━━━━━━━━━━━━━━━━ 🔹 WHY does it happen? 🧠 Environment Locking JavaScript closures freeze the scope they were created in. ⚠️ Logic Errors Timers or handlers read outdated values → UI feels broken. 📦 Hook Dependency Rules This is exactly why dependency arrays exist in useEffect and useCallback. Ignoring dependencies = stale data risk. ━━━━━━━━━━━━━━━━━━━━━━ 🔹 HOW does it occur? Classic mistake: const [count, setCount] = useState(0); useEffect(() => { const id = setInterval(() => { // ❌ STALE: 'count' is always 0 console.log(count); }, 1000); return () => clearInterval(id); }, []); // Empty dependency array Here: • Effect runs only once • Closure captures count = 0 • Interval never sees updated state ✅ Fix 1: Add Dependency useEffect(() => { const id = setInterval(() => { console.log(count); }, 1000); return () => clearInterval(id); }, [count]); ✅ Fix 2: Use Functional Update setCount(c => c + 1); Functional updates always use the latest value. ━━━━━━━━━━━━━━━━━━━━━━ 🔹 WHERE does this bug appear? ⏱ Intervals & Timeouts setInterval reading outdated state. 🌍 Manual Event Listeners window.addEventListener referencing old values. 🧩 useCallback / useMemo Memoized functions missing dependencies. Any long-lived function = risk of stale closure. ━━━━━━━━━━━━━━━━━━━━━━ 📝 SUMMARY A Stale Closure is like Navigating with an Old Map 🗺️ You’re using a map from 1990 (old render) to find a building built in 2026 (current state). The map is stuck in time. So you reach the wrong destination. Always update your map (Dependencies). ━━━━━━━━━━━━━━━━━━━━━━ 👇 Comment “React” if this series is helping you 🔁 Share with someone mastering React hooks #ReactJS #StaleClosures #useEffect #JavaScriptClosures #FrontendDebugging #Top150ReactQuestions #LearningInPublic #Developers ━━━━━━━━━━━━━━━━━━━━━━
To view or add a comment, sign in
-
-
How to Design a URL Shortener (like Bitly) – Interview Perspective Most candidates jump straight into coding. Strong candidates start with questions. Here’s how I would approach it in a System Design interview 👇 1️⃣ Clarify Requirements Functional: * User submits long URL * System returns short URL * Redirect short → original URL Non-functional: * High read traffic (redirection heavy) * Low latency (<100ms) * High availability * Scalable to billions of URLs 2️⃣ Basic Design Client → API Server → Database POST /shorten GET /{shortCode} Simple… but not scalable yet. 3️⃣ Key Design Decisions 🔹 How to generate short code? * Auto-increment ID + Base62 encoding * Random string (collision handling needed) * Hash of URL (collision + duplication concerns) Best interview answer: Auto-increment ID → encode to Base62 Why? * Guaranteed uniqueness * Short length * No collision checks 4️⃣ Database Choice Relational DB works fine initially. Table: id | short_code | long_url | created_at Index on short_code (very important) 5️⃣ Scaling Read Traffic Reads >> Writes So: * Add Redis cache * Cache short_code → long_url * Cache miss → DB → populate cache 6️⃣ Handling Scale * Horizontal scaling of API servers * Database replication (read replicas) * CDN for global redirection 7️⃣ Advanced Discussion (What impresses interviewers) * Rate limiting (avoid abuse) * Expiry support * Custom aliases * Analytics (click count tracking) * Prevent malicious URLs * Consistency vs Availability trade-off 8️⃣ Bottleneck? Database write throughput. Solution: * Sharding * Pre-generated ID blocks * Snowflake-like ID generation Interview Tip: Don’t try to design Bitly v5.0. 1️⃣ Start simple. 2️⃣ Scale step by step. 3️⃣ Explain trade-offs clearly. That’s what interviewers are evaluating. Here are some solid resources to go deeper: 🎥 Design URL Shortener – https://lnkd.in/gMqqZbUY 🎥 How Does a URL Shortener Work? - https://lnkd.in/gJyCR6w7 🎥 TinyURL System Design - https://lnkd.in/ggqrzHEj Ankit Pangasa
To view or add a comment, sign in
-
-
Getting ready for system design interviews always felt like trying to boil the ocean. When I first started looking into it, I thought I needed to memorize every whitepaper on Kafka or Cassandra just to stand a chance. But after diving deep into how to actually prepare, I’ve realized it’s much less about being a walking encyclopedia and much more about having a solid game plan. If you’re an SDE like me trying to make sense of the madness, here is the structured way I’m approaching my preparation: The Foundation (Don't skip the basics) You can’t design a distributed system if you don’t truly understand the building blocks. I’m spending time making sure I can explain exactly when to use a Load Balancer, the real difference between SQL and NoSQL in a crunch, and how Caching actually saves a failing system. Master a Framework The biggest mistake is jumping straight into drawing boxes. The goal is to have a mental checklist you can follow every single time: 1. Clarify the requirements first (What are we actually building?) 2. Estimate the scale (Are we talking thousands or millions of users?) 3. Map out the high-level flow. 4. Then, and only then, dive into the deep technical bottlenecks. Deep Dives on Common Problems Most interviews revolve around a few classic scenarios think "Design Twitter" or "Design a Web Crawler." Instead of memorizing the "correct" answer, I’m focusing on the unique challenges of each. For a chat app, the challenge is real-time delivery; for an ad-tech platform, it’s extreme low latency. Mock Interviews are Everything Reading about system design is passive. Explaining it out loud while someone pokes holes in your logic is where the real learning happens. I’ve started doing mocks with peers because it forces you to justify your trade-offs in real time. Focus on Signal, Not Just Noise At the end of the day, the interviewer wants to see if you can think like an owner. They aren't just looking for "The Right Database." They want to see how you handle ambiguity, how you communicate your ideas, and if you can identify where your own design might break. It’s a marathon, not a sprint. System design is a muscle that takes time to build, but having a roadmap makes it feel a lot less overwhelming. How are you all tackling your interview prep lately? Any specific resources or strategies that clicked for you? #SystemDesign #SoftwareEngineering #TechInterviews #SDE #CareerGrowth
To view or add a comment, sign in
-
web-fundamentals-tcpip-debugging-interview-q 🚨 Interview Trap: "My API is slow, let's optimize the database!" Stop. Before you refactor code, check the wire. 🛑 In 2026, with complex microservices and containerized environments, web performance bottlenecks often hide in the `TCP/IP` layer, not the application logic. 🔹 **The Senior-Level Breakdown:** Understanding `TCP` behavior is critical when: • You see high `RTT` causing `Slow Start` delays on mobile networks. • `Packet loss` triggers `Congestion Control` algorithms (like `CUBIC` or `BBR`) to throttle throughput. • `TCP Window Scaling` is misconfigured, capping your bandwidth on high-speed links. • `Head-of-Line Blocking` in `TCP` (vs `QUIC/HTTP3`) stalls multiple requests on a single connection. 🛠️ **The Fix:** Don't just guess. Use `tcpdump`, `Wireshark`, or modern `eBPF` tracing to visualize `ACK` delays, `RST` flags, and `CWND` behavior. If the `TCP handshake` or `retransmissions` are the issue, no amount of backend optimization will help. Found this useful? Follow for more such interview questions and save post for your next prep session! #WebFundamentals,#WebDev,#Interviews,#CodingTips,#NetworkEngineering
To view or add a comment, sign in
-
-
Singleton ----- let’s go deeper — this is where most interview questions come from. 🔐 1. Thread-Safe Singleton (VERY IMPORTANT) ❓ Problem In many languages, Singleton is tricky because: 👉 Multiple threads might create multiple instances at the same time. ✅ Swift Solution (Modern Swift) Swift final class NetworkManager { static let shared = NetworkManager() private init() { print("Initialized once") } } 🧠 Why this is already thread-safe? 👉 Swift uses lazy initialization for static let Behind the scenes: Created only when first accessed Guaranteed once-only initialization Handled by Swift runtime (no race condition) 👉 ✅ So this is automatically thread-safe ⚠️ Old (Wrong) Approach – DON’T USE Swift class NetworkManager { static var shared: NetworkManager? class func getInstance() -> NetworkManager { if shared == nil { shared = NetworkManager() } return shared! } } ❌ Problem: Not thread-safe Two threads can create two objects 🧠 Interview Line “In Swift, static let makes Singleton thread-safe by default due to lazy and atomic initialization.” ⚡ 2. Lazy vs Static Singleton 🔹 Static Singleton (Best ✅) Swift static let shared = NetworkManager() ✔ Thread-safe ✔ Simple ✔ Preferred 🔹 Lazy Singleton (Manual) Swift class NetworkManager { static var shared: NetworkManager = { let instance = NetworkManager() return instance }() private init() {} } ✔ Also lazy ✔ Thread-safe ❗ Slightly more verbose 👉 Use this only if you need custom setup logic ⚠️ 3. Singleton Pitfalls (VERY IMPORTANT) ❌ 1. Global State Problem Swift NetworkManager.shared.userToken = "ABC" 👉 Accessible everywhere → hard to track changes 👉 Leads to bugs ❌ 2. Hard to Test 👉 You can’t easily mock: Swift NetworkManager.shared.fetchData() ❌ No flexibility to inject fake data ❌ 3. Tight Coupling Every class depends on: Swift NetworkManager.shared 👉 Makes code less reusable ✅ Better Approach (Dependency Injection) Instead of: Swift NetworkManager.shared.fetchData() Use: Swift class HomeViewModel { let networkManager: NetworkManager init(networkManager: NetworkManager = .shared) { self.networkManager = networkManager } } ✔ Testable ✔ Flexible ✔ Clean architecture 🚀 4. Singleton in SwiftUI (Real Usage) Example: User Session Swift final class UserSession: ObservableObject { static let shared = UserSession() @Published var isLoggedIn = false private init() {} } Usage in View Swift @StateObject var session = UserSession.shared 👉 Now UI updates automatically 🎯 When to Use Singleton ✅ Use when: One shared resource needed Examples: Network layer Cache manager User session Analytics ❌ Avoid when: You need flexibility You need multiple instances You care about testability #iOS #Swift #SwiftUI #iOSDeveloper #iOSDevelopment #SwiftProgramming #SwiftDeveloper #SwiftConcurrency #AppleDeveloper #Xcode #MobileDev
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development