DAY 3| WHY DO WE ALWAYS USE CONST FOR FUNCTIONS IN REACT? 🤔 If you look at React code, you’ll see this everywhere 👇 const handleClick = () => { console.log("Clicked"); }; In React, functions are not meant to change. Using const keeps: 👉 the function fixed 👉 behavior predictable 👉 UI updates stable That’s why this pattern shows up again and again in React code. 💬 If this helped you, share your thoughts. #ReactJS #JavaScript #FrontendDevelopment #WebDevelopment #LearnInPublic #CodingJourney #SoftwareEngineering
React Functions: Why Use Const?
More Relevant Posts
-
Something new I learned about React today… I thought setState() updates immediately. But React batches state updates. Example: 👉 setCount(count + 1); 👉 setCount(count + 1); You might expect +2… But it becomes +1. Why? React queues updates and processes them together in the next render cycle. Both calls use the same previous count value. Why does React do this? Because DOM updates are expensive. Batching helps: ✅ Reduce unnecessary re-renders ✅ Improve performance ✅ Keep UI updates efficient Correct way when depending on previous state: 👉 setCount(prev => prev + 1); 👉 setCount(prev => prev + 1); 💡 Realization: State updates are scheduled, not instant. #ReactJS #JavaScript #FrontendDevelopment #WebDevelopment #SoftwareEngineering #CodingJourney #LearningInPublic #DeveloperLife #ReactInternals #FrontendEngineer #TechInterview #StateManagement
To view or add a comment, sign in
-
🚀 React Re-renders Why does a component re-render even when props look the same? React re-renders when reference changes, not value. If you pass new objects/functions every render, React treats them as new. Example: Passing `{ user }` where `user` is recreated each render will trigger child updates. In dashboards with 100+ rows, this causes lag. Fix: Memoize values and avoid inline object creation. #ReactJS #FrontendEngineering #JavaScript
To view or add a comment, sign in
-
🚀 Day 897 of #900DaysOfCode ⚛️ Understanding the Virtual DOM in React In today’s post, I’ve explained what the Virtual DOM is and why React uses it. You’ll understand: - What the Virtual DOM actually represents - How React compares changes (diffing) - Why updates become faster and more efficient - How it improves performance and user experience This concept often feels confusing at first, but once it clicks, a lot of React internals start making sense. 👇 Was Virtual DOM confusing for you when you started with React? #Day897 #learningoftheday #900daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #React #CodingCommunity #VirtualDOM
To view or add a comment, sign in
-
Sometimes, a component is the wrong tool for the job. If you need to perform low-level DOM manipulation — like automatically focusing an input or adding a tooltip. Instead of cluttering your component logic with refs and onMounted hooks, you can encapsulate that behavior in a directive like v-focus or v-tooltip. It keeps your template clean: <input v-focus /> And the logic is reusable across your entire app without the overhead of a full component instance. ☺️🤖 #vuejs #frontend #javascript #webdev #codingtips
To view or add a comment, sign in
-
🔐 React Password Generator This is a simple React project, but it uses very useful concepts. The project helped me understand how React manages state, updates the UI, and works with real-world features like copy-to-clipboard. Concepts used: -React Hooks (useState) -Controlled inputs -Event handling -Random number generation -Clipboard API 📂 GitHub Repo: https://lnkd.in/gu3fdw_f #ReactJS #FrontendDevelopment #JavaScript #LearningByDoing #WebDevelopment
To view or add a comment, sign in
-
-
🚨 Stop using useEffect for everything in React. If you're still using useEffect to: • Derive state from props • Transform data for rendering • Handle simple computations You're probably writing more bugs than you think. 💡 React tip: 1️⃣ Derived data belongs in useMemo, not useEffect 2️⃣ Event-driven logic belongs in handlers 3️⃣ Effects are for synchronization with external systems The less useEffect you write, the more predictable your component becomes. Clean React code is about eliminating unnecessary effects. What’s one place you removed useEffect and simplified your code? #ReactJS #FrontendDevelopment #JavaScript #SoftwareEngineering #CleanCode
To view or add a comment, sign in
-
🚀 Understanding the useEffect Hook in React useEffect is a powerful hook used to handle side effects in functional components, such as: API calls Subscriptions & event listeners Timers Cleanup on unmount Key concepts covered ✔️ Mount → runs after initial render ✔️ Update → re-runs when dependencies change ✔️ Unmount → cleanup to prevent memory leaks ✔️ Dependency array → controls when the effect runs Strong understanding of hooks leads to cleaner, scalable, and more predictable React applications. #ReactJS #useEffect #FrontendDevelopment #JavaScript #WebDevelopment #ReactHooks #SoftwareEngineering #LearningJourney
To view or add a comment, sign in
-
-
Today I explored Form Handling & Routing in React. Key takeaways: Managing form state with useState Implementing basic form validations Navigating between pages using BrowserRouter Building forms that actually validate and route correctly feels like a big step toward real-world applications. Onward and upward! 💪 #ReactJS #MERNStack #WebDevelopment #Frontend #LearningInPublic #JavaScript #ReactRouter
To view or add a comment, sign in
-
-
🚀 Understanding Reconciliation in React.js One of the core concepts that makes React powerful and efficient is Reconciliation. When state or props change, React doesn’t blindly update the entire DOM. Instead, it: 1️⃣ Creates a new Virtual DOM 2️⃣ Compares it with the previous Virtual DOM (Diffing) 3️⃣ Identifies what actually changed 4️⃣ Updates only those specific parts in the Browser DOM This process is called Reconciliation. 💡 Why is this important? Because updating the real DOM is expensive. By updating only the changed elements, React ensures high performance and smooth UI updates. 🔑 Key takeaway: Same element type → Update only changed props Different element type → Destroy and rebuild Lists require proper keys for efficient diffing Understanding reconciliation helps you write better, optimized React applications. #ReactJS #FrontendDevelopment #WebDevelopment #JavaScript #VirtualDOM #ReactDeveloper #SoftwareEngineering #CodingJourney #TechLearning
To view or add a comment, sign in
-
-
👋 Hi! 🌱 Today's topic - React Hook "useState". IN React, normal variables do not update the UI when their values change. so The useState hook helps us store that can change over time and ensures the UI re-renders automatically whenever the state updates. It returns: The current state value A function to update that value Uses: Counter applications Form input handling Toggle buttons and Displaying dynamic data #ReactJS #useState #frontendDevelopment #Javascript #Learningjourney.
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