React developers sometimes face tricky behavior of React. For example: in some specific situations, same-name component-instances re-render each other, instead of doing a fresh independent new mount. This image shows this tricky situation and the solution which is the "key" prop of a component. The different "key" prop forces the component to behave independently even if it has the same name ("Item"). Tags: React, React.js, ReactJS, TypeScript, JavaScript, Zustand, Redux Toolkit, Tailwind, CSS, MUI, MaterialUI, ChakraUI, SVG, Portfolio: https://lnkd.in/dPq6PNuH
React Component Re-renders with Same Name
More Relevant Posts
-
React devs — this is why you’re running out of API limits. Most React beginners make this mistake with useEffect.... And it looks completely harmless. 𝗧𝗵𝗲𝘆 𝘄𝗿𝗶𝘁𝗲 𝘁𝗵𝗶𝘀: useEffect(() => { fetchData() }) No dependency array. 𝗧𝗵𝗲 𝗽𝗿𝗼𝗯𝗹𝗲𝗺 𝗶𝘀, This runs after EVERY render. Not once. Not on mount. 𝗘𝗩𝗘𝗥𝗬 render. If your effect updates state: it triggers a re-render, which re-runs the effects causing infinite API calls. That's when your app breaks. 𝗧𝗵𝗲 𝗳𝗶𝘅 𝗶𝘀 𝘀𝗶𝗺𝗽𝗹𝗲: useEffect(() => { fetchData() }, []) // empty array = runs once on mount 𝗛𝗲𝗿𝗲'𝘀 𝘄𝗵𝗲𝗻 𝗲𝗮𝗰𝗵 𝘃𝗲𝗿𝘀𝗶𝗼𝗻 𝗿𝘂𝗻𝘀: → No array = runs after every render → Empty array = runs once on mount → [value] = runs when value changes Save this — you 𝗪𝗜𝗟𝗟 hit this bug again. Which useEffect mistake have you made before? Drop it below 👇 Follow for more React tips that save you hours of debugging. #reactjs #webdevelopment #javascript #MERN
To view or add a comment, sign in
-
-
Understanding State Management in React JS is a game changer for every frontend developer 🚀 From managing simple local states to handling complex global data, mastering this concept helps you build scalable and efficient applications. In this post, I’ve simplified: ✔ What is State ✔ How it works in React ✔ Local vs Global State ✔ Popular tools like Context API, Redux & Zustand If you're learning React, this is one concept you can't afford to ignore 💡 👉 Save this post for later & share your thoughts in the comments CODING OF WORLD #ReactJS #WebDevelopment #FrontendDevelopment #JavaScript
To view or add a comment, sign in
-
-
TypeScript Started. Migrating SafelyRest from JavaScript to TypeScript Links:- • GitHub https://lnkd.in/gwfXsp_3 • App https://lnkd.in/d5JnhrGz • Configured "tsconfig" with strict mode • Added strong typing across controllers, services, and models • Replaced "any" with proper types, interfaces, and generics • Implemented type-safe API requests/responses • Added types for env variables and external libraries • Improved async handling with proper Promise types • Better debugging with compile-time error detection #typescript #javascript #backend #fullstack #nodejs #webdevelopment
To view or add a comment, sign in
-
-
🔹 React Basics: Props vs State (Explained Simply) When starting with React, one of the most important concepts to understand is the difference between Props and State. Here’s a simple breakdown 👇 👉 Props (Properties) • Passed from parent to child components • Read-only (cannot be modified) • Used to make components reusable 👉 State • Managed within the component • Can be updated using hooks like `useState` • Controls dynamic data and UI behavior 💡 In short: Props help you pass data, while State helps you manage data. Understanding this difference is key to building scalable and maintainable React applications. If you're learning React, mastering these fundamentals will make your journey much smoother 🚀 💬 What topic should I cover next in React? #ReactJS #FrontendDevelopment #JavaScript #WebDevelopment #LearningInPublic #SoftwareDevelopment #CodingJourney #Developers
To view or add a comment, sign in
-
-
Most React devs bring their SPA habits into Next.js — and their users pay the price. 👇 You've written it a hundred times: useState for data, useEffect to fetch it, a spinner while they wait. It works in React. In Next.js App Router, it's the wrong pattern entirely. Server Components let you fetch data inside the component — on the server, before the page hits the browser. No loading state. No extra JS bundle. No hydration issues. HTML that arrives ready. I've swapped dozens of useEffect fetch patterns for async Server Components and the Lighthouse scores jump immediately. Use the server for reads. Use useEffect for things only the browser can do. #NextJS #ReactJS #WebDevelopment #JavaScript #TypeScript #AppRouter #ServerComponents #ReactHooks #FrontendDeveloper #SoftwareEngineer #CleanCode #100DaysOfCode #WebPerformance #Programming #WebDev #NextJS14 #FullStackDeveloper #CodeQuality
To view or add a comment, sign in
-
-
🚀 React Quick Revision Here are some important React concepts explained in short 🔹 1) Which is the entry file in React? 👉 In most React apps, the entry file is index.js / main.jsx 👉 It is responsible for rendering the root component: ReactDOM.createRoot(document.getElementById("root")).render(<App />); 🔹 2) What is the datatype of useEffect second argument? 👉 It is an Array useEffect(() => {}, [dependency]); 👉 This array is called the dependency array and controls when the effect runs. 🔹 3) useState syntax explanation (arrow understanding) const [state, setState] = useState(initialValue); 👉 Breakdown: const → variable declaration [state, setState] → array destructuring useState() → hook function setState → function to update state 👉 Arrow meaning: setState is a function → used to update value 🔹 4) Difference between Tag and Component 👉 Tag (HTML Element): <div>Hello</div> Built-in HTML element Lowercase naming 👉 Component (React): <MyComponent /> Custom reusable function Always starts with uppercase Returns JSX #ReactJS #FrontendDeveloper #JavaScript #WebDevelopment #Learning
To view or add a comment, sign in
-
most React developers use useCallback wrong. not because they don't understand it. because they were taught the wrong rule. the rule they heard: "wrap functions in useCallback to prevent unnecessary re-renders. the actual rule: useCallback only helps when you pass that function to a child component wrapped in React.memo or as a dependency in useEffect. that's it. useCallback doesn't prevent re-renders of the parent. it just memoizes the function reference so children don't see a "new" function every render. three questions to ask before reaching for useCallback: - is this function passed to a memoized child component? - is this function a dependency in a useEffect? - is this function expensive to recreate? if none of these just write the function normally. the best optimisation is usually the one you don't add. #reactjs #typescript #webdevelopment #buildinpublic #javascript
To view or add a comment, sign in
-
-
I used to think I understood React state… until this small thing proved me wrong. I wrote this: setCount(count + 1) setCount(count + 1) setCount(count + 1) And I was expecting the count to go up by 3. But it only increased by 1. At first, it made no sense. Then I realized what was actually happening… React doesn’t update state immediately. It batches those updates and runs them later. So all three lines were using the same old value of `count`. Basically, I was doing: 0 → 1, 0 → 1, 0 → 1 Final result: 1 That’s when I learned to use functional updates: setCount(prev => prev + 1) Now each update gets the latest value: 0 → 1 → 2 → 3 Such a small change, but it completely fixed the logic. Since then, I follow one simple rule: 👉 If the new state depends on the previous one, always use a function. It’s one of those things that seems obvious later… but only after it breaks your code once 😅 Curious — has something like this ever confused you in React? #react #javascript
To view or add a comment, sign in
-
-
🚀 Leveling up my React JS knowledge! Here's what I learned this week — explained simply 👇 ⚛️ 1. Reconciliation React doesn't re-render the entire DOM every time. It compares the old and new Virtual DOM, finds the difference, and updates ONLY what changed. Result? Blazing fast UI! 🔥 🔄 2. Batch Updating React is smart — it groups multiple state updates together and re-renders ONCE instead of multiple times. Fewer re-renders = better performance! 💡 👶 3. Children Prop Want to pass content between component tags? That's the children prop! It makes components flexible and reusable — like a wrapper that accepts anything inside it. 🎛️ 4. Controlled vs Uncontrolled Inputs ✅ Controlled → React controls the input value via state. You're in full control. ❌ Uncontrolled → The DOM handles the value using refs. Less code, less control. Controlled inputs = predictable, testable, and recommended! ✅ Every concept I learn makes me a better developer. 💪 Still learning. Still growing. 🌱 #ReactJS #JavaScript #WebDevelopment #Frontend #100DaysOfCode #LearningInPublic
To view or add a comment, sign in
-
-
⚛️ React Devs — Why Your Forms Become a Nightmare at Scale Hey devs 👋 Small forms are easy… But large, dynamic forms? 💥 Total chaos: Too many states Validation everywhere Re-renders on every keystroke 👉 I’ve seen this happen in real projects. 💡 What actually works: ✔ Controlled vs uncontrolled balance ✔ Use libraries wisely (React Hook Form) ✔ Avoid unnecessary state updates ✔ Debounce expensive validations ⚡ Insight: “Not everything needs to be in state.” 👉 Senior rule: The more state you manage… the more bugs you invite. How do you handle complex forms in React? #reactjs #forms #frontendarchitecture #reacthookform #webdevelopment #frontenddeveloper #javascriptdeveloper #scalablefrontend #softwareengineering #reactperformance
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