Day 5 — State: Managing Data Inside Components ⚛️ State is used to store data that changes over time inside a component. State makes UI interactive When state updates → React re-renders the UI Managed inside the component Updated using useState Example const [count, setCount] = useState(0); <button onClick={() => setCount(count + 1)}> Count: {count} </button> 📌 Click → State changes → UI updates automatically State vs Props Props → Read-only, passed from parent State → Changeable, owned by component 🧠 In one line: State lets React components remember and update dynamic data. #React #ReactTips #LearnReact
React State Management: Storing Dynamic Data Inside Components
More Relevant Posts
-
I will show you a cool thing in React → that can make heavy UI updates feel much smoother It’s called useDeferredValue. When your UI triggers expensive renders — like large lists, complex filters, or heavy charts — every keystroke can force React to recalculate everything. This can make the interface feel slow while the user is typing. useDeferredValue allows React to prioritize the user’s interaction first and defer the expensive update to happen slightly later. In the video, I’m typing at the same speed on both inputs, so the difference comes only from how React schedules the updates. Situations where this is useful: • search inputs filtering large datasets • dashboards with charts • tables with heavy filtering • expensive computations triggered by typing A small React feature that can noticeably improve perceived performance. #react #frontend #javascript #webdevelopment
To view or add a comment, sign in
-
🧠 𝗥𝗲𝗮𝗰𝘁 𝗣𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲 𝗧𝗶𝗽 #5: 𝒖𝒔𝒆𝑫𝒆𝒇𝒆𝒓𝒓𝒆𝒅𝑽𝒂𝒍𝒖𝒆 𝘃𝘀 𝑫𝒆𝒃𝒐𝒖𝒏𝒄𝒆 Many developers solve laggy UIs using debounce or throttle. But 𝒖𝒔𝒆𝑫𝒆𝒇𝒆𝒓𝒓𝒆𝒅𝑽𝒂𝒍𝒖𝒆 solves a different problem. Debounce: • Waits before updating • Uses a fixed delay Throttle: • Limits update frequency • Still blocks rendering occasionally 𝒖𝒔𝒆𝑫𝒆𝒇𝒆𝒓𝒓𝒆𝒅𝑽𝒂𝒍𝒖𝒆: • No fixed delay • React schedules work based on device performance • Rendering is interruptible if the user keeps interacting This makes it ideal for render-heavy UI, not for reducing network calls. Example use cases: • Search results lists • Large filtered datasets • Data visualizations • Expensive components Key idea: 👉 Prioritize user interactions first 👉 Let expensive UI catch up later #React #JavaScript #FrontendPerformance
To view or add a comment, sign in
-
-
Some forms stay UI, while others quietly become rule engines. Here’s why these two different approaches exist and how to choose between them.
To view or add a comment, sign in
-
⚡ 7 Frontend Performance Tips That Help in Real Products After working on several large applications, these small practices have made a noticeable difference. 1️⃣ Lazy load heavy components - Especially dashboards and charts. 2️⃣ Avoid unnecessary re-renders - Use memoization where it actually matters. 3️⃣ Optimize images - Use next-gen formats and proper sizing. 4️⃣ Reduce bundle size - Analyze dependencies regularly. 5️⃣ Avoid over-fetching data - Fetch only what you need. 6️⃣ Use skeleton loaders instead of spinners - Improves perceived performance. 7️⃣ Monitor real user metrics - Lab performance ≠ real user performance. Performance is not a one-time fix. It’s a continuous discipline. What’s one performance trick that has worked well for you? #WebPerformance #FrontendDevelopment #ReactJS
To view or add a comment, sign in
-
𝗠𝗼𝗱𝗲𝗿𝗻𝗶𝗛𝗶𝗻𝗴 𝗪𝗲𝗯 𝗔𝗽𝗽𝗹𝗶𝗰𝗮𝗍𝗶𝗼𝗻𝘀 𝗪𝗶𝗍𝗵 𝗥𝗲𝗮𝗰𝗍 𝟭𝟵+ 𝗜𝗻𝗍𝗲𝗿𝗻𝗮𝗹𝘀 You want to improve your web applications with React 19+ internals. Here's how you can do it: - Use Concurrent Rendering and @use for data fetching and suspension. - Implement useActionState for native form interception and lifecycle management. - Use useOptimistic for zero-lag UI and rollback mechanics. Here's a breakdown of each feature: - Concurrent Rendering and @use: This feature moves the complexity of data orchestration from user code to the Fiber Reconciler. It checks if a Promise is resolved and marks the Fiber Node as Suspended if not. - useActionState: This feature lets React's Fiber Reconciler handle the entire form submission lifecycle natively. It intercepts the native form submission event and dispatches an internal Action Fiber Update. - useOptimistic: This feature provides zero-lag user feedback for critical interactions. It creates a Predicted Fiber Update on a highly prioritized lane and commits it immediately. These features work together to provide a seamless user experience. You can use them to improve your web applications and make them more efficient. Source: https://lnkd.in/gWKzRcbu
To view or add a comment, sign in
-
A lot of frontend problems are not UI problems. They’re state problems. Or data flow problems. The UI is just where the chaos becomes visible.
To view or add a comment, sign in
-
The real problem with Signals in React isn't API design. It's time. React controls time: - render (interruptible) - commit (atomic) Your reactive system controls data propagation. If these two timelines don't align: You get tearing. Most integrations ignore this completely. This one doesn't. I break down how to build a tear-free bridge using: - lazy snapshots (peek) - reactive tracking (createEffect) - React's contract (useSyncExternalStore) #react #frontend #webdevelopment #javascript #typescript #signals #reactivity
To view or add a comment, sign in
-
Building my own system taught me something uncomfortable: Frontend state lies. Not intentionally. Not maliciously. But it lies. While building my Church Management platform, I kept running into the same pattern: • The UI showed “Resend Invite” — backend rejected it. • A user disappeared from the dashboard — but still existed in Auth. • A button looked disabled — but the API could still be called. • React Query showed loading — even though data hadn’t changed. The frontend reflects assumptions. The backend enforces truth. And if those two aren’t aligned, your system drifts. That’s when I stopped relying on UI state as protection. Now I design systems with one rule: Frontend communicates intent. Backend guarantees integrity. If your business rules only exist in the UI, they don’t exist. Real engineering starts when you stop trusting what the interface tells you. Have you ever discovered your system was “correct” visually — but wrong architecturally? #BackendEngineering #SystemDesign #SoftwareArchitecture #ProductionLessons
To view or add a comment, sign in
-
I tried building a UI library using Web Components… and it kept failing. Not once. Not twice. Repeatedly. At first, I thought the problem was the tools. Vite configs breaking. Components not registering. Styles not applying. Things just… not working. But the real issue was simpler—and harder to admit: I didn’t understand what was happening under the hood. I was stacking complexity too early. Custom CLI. Auto-generated files. Build optimizations. Tree-shaking. All of it sounded “professional”… but it turned my project into a black box. When something broke, I had no idea where to even start. So I did something most people avoid: I stripped everything down. No CLI. No abstractions. No fancy setup. Just one Web Component. Built it. Broke it. Fixed it. Repeated. And that’s when things finally started to click. I began to understand: 1. How the Shadow DOM actually works (not just in theory) 2. Why styling feels restrictive—and how to work around it 3. How components communicate using custom events 4. Where integration with frameworks like React can go wrong The result? Not just a working component—but a clear mental model. And that’s the real “streamlined product” most people don’t talk about. It’s not the library. It’s the clarity. Now, rebuilding the system feels different. Simpler. Intentional. Controlled. Lesson learned: If you can’t explain your system, you shouldn’t be scaling it. Start small. Understand deeply. Then build up. #WebComponents #FrontendDevelopment #BuildInPublic #JavaScript #SoftwareEngineering
To view or add a comment, sign in
-
Recently, I faced an interesting challenge while building an infinite scrolling feed in React. Stack: • Redux Toolkit Query • Paginated API (page-based) • Infinite scroll (merged cache) Everything worked fine… until this happened 👇 👉 A user scrolled to page 10 👉 Updated an item 👉 I triggered a refetch Expected behavior: The list should refresh properly. Actual behavior with RTK Query: It refetched only page 10 — not pages 1–9. Why? Because RTK Query refetches based on the current query argument. If your query is `{ page: 10 }`, it only refetches page 10. Now imagine this scenario: • The updated item affects sorting • That item should now appear on page 1 • But only page 10 gets refetched Result? ❌ Inconsistent UI. The Workarounds in RTK Query 1️⃣ Reset pagination → fetch page 1 again (bad UX) 2️⃣ Manually refetch pages 1–10 (expensive) 3️⃣ Manually patch cache using `updateQueryData` (complex for large feeds) It works — but it requires extra architectural effort. How TanStack Query Handles This Better With TanStack Query’s `useInfiniteQuery`, each page is stored independently. Example: useInfiniteQuery({ queryKey: ['posts'], queryFn: fetchPosts, getNextPageParam: (lastPage) => lastPage.nextCursor, }) When a mutation happens: queryClient.invalidateQueries(['posts']) It refetches all active pages automatically. No manual cache merge. No page reset. No scroll break. No hacks. It simply understands the infinite query structure. Real-World Scenario User scrolls to page 10 User updates an item from page 3 Sorting changes RTK Query: • Only page 10 refetches • Page 3 remains stale TanStack Query: • All pages refetch • UI stays consistent My Take RTK Query is amazing when: ✔ You need Redux integration ✔ You want centralized state ✔ You manage moderate datasets But for complex infinite scrolling feeds: 👉 TanStack Query feels more natural 👉 Less manual cache orchestration 👉 Cleaner mental model #React #ReduxToolkit #TanStackQuery #WebDevelopment #FrontendArchitecture
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