A useful React concept that changed how I write code 👇 One of the most important patterns I’ve learned in React is the difference between State vs Props vs Derived State — and when not to create extra state. Instead of storing everything in useState, I now follow this approach: • Use props for data that comes from parent components • Use state (useState) only when the value actually changes over time • Avoid derived state — compute values directly from props whenever possible • Lift state up when multiple components need the same data • Keep components small, focused, and predictable Example mindset: If a value can be calculated from existing props, I don’t store it in state — I derive it inside the component. This reduces bugs, unnecessary renders, and keeps data flow cleaner. This simple shift has made my React code more maintainable and easier to debug. Still learning, still improving every day. 🚀 #ReactJS #FrontendDeveloper #WebDevelopment #LearningInPublic
State vs Props in React: Simplifying Code with Derived State
More Relevant Posts
-
🚀 30 Days of React.js Tips – Day 22 📌 Topic: Managing State in React Today’s learning was focused on state management in React, one of the most important concepts for building dynamic and scalable applications. 📚 Key Learnings from Day 22: ✔ Managing local state using the useState Hook ✔ Sharing data across components with the Context API ✔ Handling complex logic using the useReducer Hook ✔ When to lift state up to a parent component ✔ Introduction to global state management libraries like Redux, Zustand, and Recoil 💡 Why State Management Matters: State controls how your UI behaves. Proper state management ensures your application stays predictable, maintainable, and easy to debug as it grows. 🔑 Key Insight: 👉 Not all state should be global — choose the right level for your state. 📈 Learning React step by step — consistency beats intensity. 💬 Comment “State” if you’re improving your state management skills 👇 👍 Like & share to support this learning journey #30DaysOfReact #ReactJS #StateManagement #ReactHooks #FrontendDevelopment #WebDevelopment #JavaScript #MERNStack #LearnInPublic
To view or add a comment, sign in
-
-
5 years into building with Websites and Apps, and I’ll be honest… I could have saved myself a lot of time if I had discovered the right tools earlier. 👉Postman - I used to test APIs by console.logging everything. Never again. 👉Zustand - Replaced Redux in one of my projects. Went from 200 lines of boilerplate to 20. Seriously. 👉React Query - Was manually writing useEffect + useState for every API call. React Query made me feel like I was cheating 😂 👉Prisma - Built a timesheet app last year. Writing raw SQL queries was killing me. Switched to Prisma mid-project and never looked back. 👉Railway / Render - Deployed a Node.js REST API for a side project in under 10 minutes. No DevOps knowledge needed. 👉Josh W Comeau's blog -His article on CSS-in-JS and React rendering changed how I think about performance. Bookmark it. If I had found these 5 years ago, I'd have shipped 2x faster. What's one tool that changed how you code? Drop it below 👇 #FullStackDeveloper #ReactJS #NodeJS #JavaScript #WebDevelopment #DeveloperTools #SoftwareEngineering
To view or add a comment, sign in
-
𝗧𝗵𝗲 𝗺𝗼𝗺𝗲𝗻𝘁 𝗥𝗲𝗮𝗰𝘁 𝘀𝘁𝗮𝗿𝘁𝘀 𝗺𝗮𝗸𝗶𝗻𝗴 𝘀𝗲𝗻𝘀𝗲 There is a specific moment in every developer’s journey. Until that point: React feels confusing. Components feel messy. State feels unpredictable. APIs feel chaotic. And then suddenly… Everything becomes structured. What changes? Not syntax. Not hooks. Not libraries. The shift happens when you start thinking in terms of: • Data flow • Component responsibility • State ownership • Reusability • Separation of concerns When you stop asking: “How do I build this page?” And start asking: “How should this application behave?” That’s when React becomes powerful. Real projects are not built page by page. They are built by designing: – where state lives – how components communicate – how APIs integrate – how errors are handled – how performance is managed Most developers don’t struggle because React is difficult. They struggle because no one teaches them how to think about applications. Once that mindset changes — React stops being overwhelming and starts being elegant. And that is the difference between: Learning React and Working with React. #ReactJS #FrontendDevelopment #WebDevelopment #JavaScript #MERNStack #SoftwareEngineering #tejaxglobalinnovations
To view or add a comment, sign in
-
-
While interacting with many people learning React, one thing consistently stands out. Most developers don’t struggle with React because of JavaScript. The real difficulty comes from this — tutorials show how to create components, but real projects require understanding how an application actually works. When someone begins to understand where state belongs, how data flows across components, and how different parts of the UI communicate — React suddenly feels much clearer. That transition from “building pages” to “designing applications” is what truly transforms a learner into a developer. #panabakajayaprakash
𝗧𝗵𝗲 𝗺𝗼𝗺𝗲𝗻𝘁 𝗥𝗲𝗮𝗰𝘁 𝘀𝘁𝗮𝗿𝘁𝘀 𝗺𝗮𝗸𝗶𝗻𝗴 𝘀𝗲𝗻𝘀𝗲 There is a specific moment in every developer’s journey. Until that point: React feels confusing. Components feel messy. State feels unpredictable. APIs feel chaotic. And then suddenly… Everything becomes structured. What changes? Not syntax. Not hooks. Not libraries. The shift happens when you start thinking in terms of: • Data flow • Component responsibility • State ownership • Reusability • Separation of concerns When you stop asking: “How do I build this page?” And start asking: “How should this application behave?” That’s when React becomes powerful. Real projects are not built page by page. They are built by designing: – where state lives – how components communicate – how APIs integrate – how errors are handled – how performance is managed Most developers don’t struggle because React is difficult. They struggle because no one teaches them how to think about applications. Once that mindset changes — React stops being overwhelming and starts being elegant. And that is the difference between: Learning React and Working with React. #ReactJS #FrontendDevelopment #WebDevelopment #JavaScript #MERNStack #SoftwareEngineering #tejaxglobalinnovations
To view or add a comment, sign in
-
-
After 3 years of working with React and Next.js, one important lesson I’ve learned about state management is: Redux is powerful — but it should be used wisely. Why use Redux? Redux is a great choice when your application has: Complex and large-scale state Data that needs to be shared across multiple components or pages Multiple API calls with loading and error handling A need for predictable state flow with a single source of truth Easier debugging using Redux DevTools In larger projects like dashboards or applications with user sessions, global data, and frequent updates, Redux Toolkit makes state management much cleaner and more scalable. Cons of Redux From practical experience, Redux also comes with some challenges: Extra setup and initial configuration Can feel like overkill for small or medium projects Adds complexity if the state is simple Slight learning curve for beginners More code compared to local state or Context API My takeaway Use Redux when your application actually needs global and complex state. For smaller apps, tools like useState, useReducer, or Context API might be simpler and more efficient. Good development is not about using the most powerful tool — it’s about choosing the right tool for the problem. What do you prefer for state management in your projects — Redux, Context API, or something else? #React #Redux #ReduxToolkit #FrontendDeveloper #NextJS #JavaScript #WebDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
-
Built a fun little weekend project — and learned more than I expected. 🛩️ Introducing PaperPlane — an anonymous messaging app where anyone can send you a message, no account needed. Think NGL, but with its own personality. I built this by following Hitesh Choudhary's Next.js tutorial — but I didn't stop there. I used it as a foundation to actually understand the stack, then extended it with features and UX decisions that were entirely my own: → OTP email verification for receivers → AI-suggested messages based on a receiver's personality (a bit of prompt engineering with a free LLM via OpenRouter) → A day-to-night theme progression across the full user journey → Edge cases that most tutorial projects never think about — wrong redirects, username conflicts, graceful 404s → Rate limiting on sensitive API routes (post-build addition!) Stack: Next.js (fullstack) · NextAuth.js · MongoDB · shadcn/ui + Tailwind · Nodemailer · OpenRouter The real win wasn't the app itself — it was the moment copy-pasted code stopped working and I had to actually understand what was happening to fix it. That's where the learning lives. Not a project that'll cure cancer. But a genuinely fun one that levelled up how I think about fullstack development. 🚀 🔗 Live demo in the comments — would love for you to send me a paperplane 👀 #NextJS #WebDevelopment #buildinpublic #100DaysOfCode #JavaScript #TypeScript
To view or add a comment, sign in
-
𝐄𝐯𝐞𝐧 𝐚𝐬 𝐚𝐧 𝐞𝐱𝐩𝐞𝐫𝐢𝐞𝐧𝐜𝐞𝐝 𝐝𝐞𝐯𝐞𝐥𝐨𝐩𝐞𝐫, 𝐈 𝐬𝐭𝐢𝐥𝐥 𝐬𝐨𝐦𝐞𝐭𝐢𝐦𝐞𝐬 𝐦𝐚𝐤𝐞 𝐬𝐢𝐦𝐩𝐥𝐞 𝐦𝐢𝐬𝐭𝐚𝐤𝐞𝐬. Today React threw: ❌ “Uncaught Error: input is a void element tag and must neither have children nor use dangerouslySetInnerHTML” I checked the code twice and didn’t notice it at first. I had written: <𝑖𝑛𝑝𝑢𝑡> 𝐸𝑛𝑡𝑒𝑟 𝑛𝑎𝑚𝑒 </𝑖𝑛𝑝𝑢𝑡> I wrote it almost automatically… and didn’t even realize. The issue? <input> is a void element in HTML. That means: 1️⃣ No children 2️⃣ No closing tag 3️⃣ Must be self-closing <𝑖𝑛𝑝𝑢𝑡 𝑡𝑦𝑝𝑒="𝑡𝑒𝑥𝑡" /> 💡 Reminder: Experience doesn’t mean you stop making mistakes. It means you understand them faster. Frameworks don’t replace fundamentals. They enforce them. #ReactJS #FrontendEngineering #LearningNeverStops #WebDevelopment
To view or add a comment, sign in
-
Why useEffect Is the Most Misunderstood Hook in React 📢 When I first started using React, I thought useEffect was simple. “Run this after render.” That’s it. But the more I worked with it, the more I realized… useEffect is not about lifecycle. It’s about synchronization. The Biggest Misunderstanding Many developers treat useEffect like: - componentDidMount - componentDidUpdate Or a place to “just put side effects” That mindset causes: - Infinite loops - Missing dependency bugs - Unnecessary API calls - Confusing behavior What useEffect Actually Is? useEffect exists to synchronize your component with something outside of React. That could be: - An API request - A subscription - A timer - The browser DOM - Local storage If there’s nothing external to sync with… You probably don’t need useEffect. The Dependency Array Is Not Optional This is where most bugs happen. When you ignore dependencies: - React re-runs the effect unexpectedly - Or worse… doesn’t re-run when it should The dependency array is not about controlling when the effect runs. It’s about telling React: “This effect depends on these values. If they change, re-sync.” That mental shift changes everything. Common Mistake Using useEffect to derive state: Common Mistake Using useEffect to derive state: useEffect(() => { setFullName(firstName + " " + lastName); }, [firstName, lastName]); You don’t need this. You can compute it directly: const fullName = firstName + " " + lastName; No effect needed. If you can calculate it during render, you don’t need useEffect. A Better Rule Before writing an effect, ask: 👉 “What external system am I synchronizing with?” If the answer is “none” — rethink it. Final Thought useEffect isn’t complicated. Our mental model is. Once you stop thinking in lifecycle terms and start thinking in synchronization terms… everything becomes clearer. Sharing what I learn about React and backend fundamentals. Follow for more practical breakdowns. . . . . . . #ReactJS #FrontendDevelopment #JavaScript #WebDevelopment #SoftwareEngineering #ReactHooks #LearnToCode
To view or add a comment, sign in
-
Mastery starts with the basics! I’ve just wrapped up a hands-on practice session building a Todo App using React and TypeScript. While it might seem like a simple project, the core logic behind it is what fuels complex, real-world applications. During this build, I focused on: State Management: Leveraging useState for dynamic data flow. Immutability: Mastering the Spread Operator [...] to handle state updates efficiently. Array Manipulation: Using .map() for rendering and .filter() to handle precise deletion logic. Type Safety: Integrating TypeScript to ensure robust data handling and catch errors during development. What's next? The logic for creating and deleting is solid, and I’m currently working on implementing a seamless Edit system to complete the full CRUD cycle! I believe that mastering these small building blocks is essential before scaling to enterprise-level projects. The journey of a thousand miles begins with a single line of code. Stay consistent, stay curious! SourceCode:https://lnkd.in/g6VFC2D5 #ReactJS #TypeScript #WebDevelopment #CodingLife #FrontendDeveloper #LearningEveryday #NextJS #JavaScript #DeveloperCommunity #BuildingInPublic
To view or add a comment, sign in
-
Most developers learn React in pieces. First — Components. Then — Hooks. Then — State Management. But the real power of React isn’t learning them separately. It’s understanding how they work together. 🧩 Components are your building blocks. They define structure and responsibility. ⚙️ Hooks give components life. They let you manage logic, side effects, and behavior. 🔄 State Management controls data flow. It decides how information moves between components. When you truly understand these three things: • We stop building messy apps. • We start designing clean architecture. • Our code becomes predictable. • Debugging becomes easier. React isn’t about writing more code. It’s about building smarter components, managing state clearly, and keeping logic reusable. Master these three — and React starts feeling simple. Just sharing a thought. #ReactJS #FrontendDevelopment #WebDevelopment #JavaScript #Coding #Developers
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