learned optional chaining in react today. making: IPL project 🏏 issue faced: accessing nested objects like "object.object.object" fix/learned: optional chaining ("?.") to avoid crashes & undefined errors small thing, big sanity save. #reactjs #webdev #buildinpublic #javascript
Optional Chaining in React for Nested Objects
More Relevant Posts
-
🚀 Day 16: Higher-Order Components (HOC) in React A Higher-Order Component (HOC) is a function that takes a component and returns a new enhanced component. 👉 Think of it as: “A wrapper that adds extra functionality to your component” Learn with JavaScript Mastery #ReactJS #FrontendDevelopment #JavaScript #CodingChallenge #LearnInPublic w3schools.com #InterviewPrep
To view or add a comment, sign in
-
-
🤯 Ever wondered why React prints old values? I finally understood stale closures by connecting it with JavaScript closures. Sharing my notes in this carousel 👇 “Slide 8 explains the real problem clearly” #React #JavaScript #FrontendDevelopment
To view or add a comment, sign in
-
most developers don't know when to stop using useState. they keep adding states until the component breaks. the problem: - multiple related states get out of sync - updates need to happen together - debugging becomes impossible the rule: - useState for single, independent values - useReducer for multiple related states - if updating one state requires updating another — use useReducer why it matters: - related state lives together - updates happen atomically - no out-of-sync bugs #reactjs #typescript #webdevelopment #buildinpublic #javascript
To view or add a comment, sign in
-
-
⚠️ Common Confusions about Control Flow : Switch case: switch-case executes all cases after a match unless you break. else if : else if chain works top-down — order matters. You can use truthy/falsy values directly in if . 🧠 Mindset Control flow = conditional storytelling. It helps your program make choices and respond differently to different inputs. Write readable branches. Avoid nesting too deep — use early return if needed. #react #javascript #JS #ABK #code
To view or add a comment, sign in
-
JavaScript Promise chaining vs async/await: Promise chains: → Harder to read → Error handling complex → Callback-ish Async/await: → Reads like sync code → try/catch works naturally → Easier debugging The choice is obvious. #JavaScript #AsyncJS #CleanCode
To view or add a comment, sign in
-
What is a closure in JavaScript? A closure is a function that remembers variables from its outer scope even after that scope has finished executing. Why does this work? - `createCounter` runs once - It creates a variable `count` - The inner function “closes over” that variable - Even after `createCounter` finishes, `count` is still accessible Each time `counter()` runs: → it uses the same preserved state 💡 Closures are everywhere: - React hooks - Event handlers - Memoization - Encapsulation patterns They’re not just a concept — they’re part of how JavaScript manages state. #Frontend #JavaScript #React #WebDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
-
Most devs reach for a state management library too fast. Before you install Redux or Zustand, try this 👇🏾 // Manage related state together, not separately const [form, setForm] = useState({ name: '', email: '', password: '' }) const handleChange = (e) => { setForm(prev => ({ ...prev, [e.target.name]: e.target.value })) } One state object. One handler. Works for 90% of forms. Stop adding dependencies before you need them. Save this 🔖 #ReactJS #JavaScript #WebDevelopment #Fullstack #CodingTips
To view or add a comment, sign in
-
-
0ms Delay... but what about the extra arguments? 🧐 Most developers know setTimeout(callback, delay), but did you know you can pass arguments directly into the callback? #JavaScript #WebDevelopment #CodingQuiz #SoftwareEngineering #FrontendTips
To view or add a comment, sign in
-
JavaScript: Mirror Distance Problem Day 5 👈 Goal: Find the mirror distance of a number — the absolute difference between the number and its reversed form. Approach: Reverse the given number using modulo (%) and division. Subtract the reversed number from the original. Take the absolute value to ensure a positive result. Example: Input: 123 Reversed: 321 Mirror Distance: |123 - 321| = 198 #JavaScript #TypeScript #DSA #CodingInterview #ProblemSolving #FrontendDevelopment #Developers #100DaysOfCode
To view or add a comment, sign in
-
-
JS Pop Quiz: Did we just overwrite the Admin?! Let’s see who really understands JavaScript memory allocation! 👨💻👩💻 Look at the code snippet from @codewithsarir. We have a user1 object. We assign it to user2, and then change user2's role to 'Guest'. Question: What does console.log(user1.role) actually print? A) 'Admin' (Because we only changed user2) B) 'Guest' (Because they share the same reference) C) undefined D) It throws a TypeError Hint: Think about how JavaScript handles Objects versus Primitive types like strings. Does = make a copy, or just point to the same address? 🤔 Drop your guess in the comments before you test it in your IDE! 👇 Hashtags: #JavaScript #CodingQuiz #WebDesign #ProgrammerLife #Developers #LearnToCode #JS #Frontend #creators #codinglife #programmer
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