useEffect vs useLayoutEffect — the difference that actually matters! Most devs use useEffect for everything, but here’s what’s happening under the hood 👇 useEffect: Runs after the paint (i.e., after the screen updates). ✅ Great for API calls, event listeners, or logging. 🚫 Avoid for DOM measurements or layout changes — you’ll see a flicker. useLayoutEffect: Runs before the paint (right after DOM mutations but before the browser updates the screen). ✅ Perfect for reading layout, measuring elements, or synchronizing animations. 🚫 Avoid overusing it — it can block rendering and hurt performance. 💡 Quick rule: If it affects what you see → use useLayoutEffect If it affects after you see → use useEffect 💬 What’s your go-to use case for useLayoutEffect? Let’s make this a mini thread of learnings 👇 #ReactJS #FrontendDevelopment #WebDevelopment #useEffect #CodingTips #JavaScript #LearnInPublic
useEffect vs useLayoutEffect: When to use each in React
More Relevant Posts
-
🚀Just Built My Own Tic-Tac-Toe Game! Today, I wrapped up a fun mini-project — an interactive Tic-Tac-Toe game built completely from scratch using HTML, CSS, and JavaScript 🧠 🎮 Play it live here - https://lnkd.in/edpeuP-4 💻 GitHub - https://lnkd.in/e2jSgUx5 This project helped me understand a lot of core JavaScript concepts, like: 🔹 DOM manipulation and dynamic updates 🔹 Event handling for player turns 🔹 Conditional logic to check win, draw, and reset states 🔹 How to create smooth UI feedback (like highlighting the winner’s line!) I also focused on making the UI playful and interactive — with animated turn indicators and color highlights that make it feel more alive ✨ It’s a simple game, but seeing it work perfectly and responding to each move made me realize how much I’ve improved at connecting logic with design. 💬Feel free to try it and share your feedback — I’d love to know what you think! #WebDevelopment #JavaScript #FrontendDevelopment #CodingJourney #LearningInPublic #MiniProject #FrontendDeveloper #HTML #CSS #GameDevelopment #TicTacToe
To view or add a comment, sign in
-
🧱 Web Development Series – Day 27 🧱 Today, I created a Dice Breakout Game using HTML, CSS, and JavaScript! 💻🎯 And it was an absolutely fantastic and thrilling experience! 🤩 In this fun and interactive project, every dice roll 🎲 controls the paddle’s power — helping to break the colorful bricks 🧱 one by one! The challenge? Keep the ball bouncing and clear the board without missing a move! ⚡ 🎮 Project Highlights: Designed the game layout with HTML & CSS 🎨 Added interactive movement and collision logic using JavaScript 🧠 Strengthened my skills in DOM manipulation, event handling, and animation control 🚀 💡 Learning takeaway: This project taught me how game logic, creativity, and JavaScript blend together to create engaging browser-based games. It’s amazing to see how much fun you can build with just a few lines of code! 💻✨ Here’s a quick look at my Dice Breakout Game: https://lnkd.in/gjbqMVdz #WebDevelopment #HTML #CSS #JavaScript #FrontendDevelopment #CodingJourney #30DaysOfCode #GameDevelopment #InteractiveProjects #CreativeCoding #FunWithCode #BreakoutGame #LearningByBuilding
To view or add a comment, sign in
-
🔥 T-Rex Run — Chrome Dino Clone with Speed Surge & Highscore Logic Tech Stack: HTML, CSS, JavaScript (Vanilla), LocalStorage Role: Solo Developer Type: Endless Runner Web Game 🧠 What It’s For T-Rex Run is a fast-paced endless runner inspired by the classic Chrome Dino game — built entirely from scratch using vanilla JavaScript. It’s for anyone who enjoys reflex challenges and wants a lightweight, browser-based game that gets faster and tougher with every run. 🛠️ How It’s Made Built with pure front-end tech — HTML, CSS, and JS — and using LocalStorage for persistent highscores. It runs fully in the browser with instant start, spacebar control, and dynamic speed scaling for challenge progression. 🧪 Tech Breakdown HTML: Layout for dino, ground, cactus, and score display CSS: Clean design, smooth animation, responsive visuals JavaScript: Jump physics, collision detection, scoring, and game loop LocalStorage: Saves highscores between sessions ✨ Feature Descriptions 🦖 Instant Start: Game starts immediately — no menus ⬆️ Spacebar Jump: Simple and responsive control 🌵 Dynamic Obstacles: Random cactus placement ⚡ Speed Surge: Game speed increases with score 🎯 +3 Scoring Logic: Every dodge adds +3 points 🎉 Highscore Celebration: Giant dino appears on new highscore 💾 Persistent Data: Highscores saved locally 📚 What I Learned Smooth jump & gravity simulation Dynamic difficulty and balancing Collision logic using JS coordinates Using LocalStorage effectively Enhancing UX with motion and timing 🧠 Personal Reflections Can we make a game like Chrome Dino that runs entirely in the browser — and even enhance it? That question started T-Rex Run. I added a speed surge mechanic, scoring system, highscore logic, and a celebratory animation — plus smoother physics and polished UI. These small upgrades turned a classic clone into a refined, rewarding web game. T-Rex Run isn’t just a remake — it’s a step in my journey that made me learn something new. I’ll keep creating, improving, and polishing — until I accomplish the goal that drives me and keeps me awake to build better every day. 🦖💨 #TReXRun #JavaScriptGame #WebGameDev #FrontendDevelopment #VanillaJS #EndlessRunner #CodingProject #LocalStorage #BrowserGames #SoloDev #GameLogic #IndieDev
To view or add a comment, sign in
-
GitHub: https://lnkd.in/eN3aYT5M 🔥 Project 10/20 – Tabs / Accordion ✨ Create Interactive Tabs using JavaScript + Active Classes + DOM! ✨ Tabs are everywhere — from dashboards to portfolios. This project teaches how to build clean, responsive tabs using: 🧩 Active class toggling for switching content 🪄 DOM manipulation for interactivity 🎨 Smooth fade animations for better UX A practical, beginner-friendly JavaScript project that boosts your UI/UX game. Switch tabs like a pro. 🚀 #webdevelopment #javascript #frontenddevelopment #frontendprojects #htmlcssjs #tabsui #accordionmenu #vanillajs #learnjavascript #programming #webdesign #techcommunity #githubproject #uicomponents #frontendinspiration #modernui #creativefrontend #webdevcommunity #codinglife #developerlife #softwareengineering #programminglife #frontendskills #interactivedesign #codewithusman
To view or add a comment, sign in
-
Why You Should Use React Three Fiber Instead of Plain Three.js in React If you're building 3D experiences in React, you might wonder: "Why use React Three Fiber (R3F) when I can just use Three.js directly?" 🔹 Using Three.js directly in React: You manually handle the scene, camera, renderer, and render loop. Syncing with React state and lifecycle can be complex and verbose. Frequent state updates can cause performance issues. 🔹 Using React Three Fiber (R3F): R3F provides a React renderer for Three.js, allowing you to write your 3D scene declaratively in JSX. Fully integrates with React state and lifecycle, making updates smooth and maintainable. Works seamlessly with helper libraries like Drei for cameras, controls, lights, and more. Optimized performance through internal batching and reconciliation. 💡 Takeaway: For small, simple animations, Three.js is fine. But for complex React projects with interactive 3D content, React Three Fiber is a cleaner, more maintainable, and high-performance solution. #threejs #r3f #3dweb #webgl #ReactJS #ThreeJS #ReactThreeFiber #WebDevelopment #3DWeb #WebGL #FrontendDevelopment #WebDesign #Coding #JavaScript
To view or add a comment, sign in
-
-
🚗 I Built This in Just 5 Hours — JavaScript Car Game 🎮 JavaScript Car Game is a fast, lightweight, browser-based infinite runner where you steer a car, dodge enemy vehicles, and chase your high score — built completely with vanilla HTML, CSS, and JavaScript (no frameworks). 💡 Core Highlights Smooth gameplay with progressive difficulty & score system Nitro boost + life recharge mechanic for strategy Day/Night mode with lighting effects Mobile-friendly UI with touch controls Persistent settings & best score saved in localStorage Background music and crash/level-up sound effects 🧠 Tech Stack: HTML | CSS | JavaScript 🔗 Live Demo: https://lnkd.in/g942eE8A 💾 Source Code: https://lnkd.in/gUtWudwz 🚀 Built this to sharpen my JavaScript and DOM-manipulation skills while exploring responsive game design for both desktop and mobile users. #JavaScript #GameDevelopment #WebGame #Frontend #WebDev #ProjectShowcase
To view or add a comment, sign in
-
🚀 Last weekend I built a Simple File Explorer simulator in React.js! A cloud-style file explorer that lets you visually browse folders and files in a tree-like structure 🌳 💡 Key features: Recursive folder structure built using React components Smooth expand/collapse animation for folders Minimal and clean UI using pure CSS (no UI libraries!) Data-driven — uses a JSON structure to render nested files/folders Deployed via GitHub Pages ➜ https://lnkd.in/dmBKjz3U Repository ➜ https://lnkd.in/daGdKcQf 🧩 Tech stack: React.js (Create React App) CSS transitions for animation GitHub Pages for hosting This was a fun mini project to brush up on component recursion and state management in React — and to see how little code it takes to create something interactive and visually appealing. Would love your thoughts or suggestions to improve it — maybe add drag-and-drop or file upload next? ⚡ #ReactJS #JavaScript #WebDevelopment #Frontend #GitHubPages #LearningByDoing #MiniProject
To view or add a comment, sign in
-
-
🚀 Just wrapped up my “Alaram” Timer project in React! ⏱️ At first glance, it looks super simple — a timer that counts down, lets you start, pause, reset, and even shows a live circular progress animation. But once I start coding it… I realize how many tiny moving parts are working behind the scenes 👇 ⚙️ What made it tricky Managing state updates every second with setInterval() ⏰ Understanding React lifecycle methods: componentDidMount() → start the timer logic componentDidUpdate() → respond to changes correctly componentWillUnmount() → clean up intervals to avoid memory leaks 🧹 Handling minute-second transitions precisely (no skipping or overlap) Syncing increment/decrement controls with real-time countdown Building a responsive gradient UI with animated progress rings 🎨 Making it all smooth and reactive without breaking the logic 😅 💡 What I learned React’s lifecycle flow is the heartbeat of every interactive component setInterval inside a class component can be both powerful and dangerous if you don’t clean it properly Visual feedback (progress rings, gradients, animations) makes even a basic timer feel alive Small logic bugs (like 60→59 rollovers) can teach you more about state timing and re-render cycles than any tutorial! 🧠 Big takeaway Simple ideas become great practice grounds for mastering state, lifecycle, and user experience in React. Even a timer can teach you how to think in React, not just code in React. 💻 💬 What’s the simplest project that taught you the most about React logic or UI state handling? Drop your answers 👇 — I’d love to see what others struggled (and triumphed) with! #ReactJS #FrontendDevelopment #WebDevelopment #LearningByBuilding #JavaScript #UIUX #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
💣 Web Development Series – Day 26 💣 Today, I built a Dice Minesweeper Game using HTML, CSS, and JavaScript! 💻🎯 And honestly — it was an absolutely fantastic experience! 🤩 In this game, each dice roll 🎲 reveals a random cell on the grid — but watch out! Some cells hide mines 💥, while others are safe 🎉. It’s all about logic, luck, and timing! ⏱️ 🎮 Project Highlights: Designed the grid layout using HTML & CSS 🎨 Added dynamic gameplay using JavaScript logic & randomization ⚙️ Practiced DOM manipulation, event handling, and game logic design 🚀 💡 Learning takeaway: This project was a perfect mix of creativity and logic. It taught me how small ideas can become interactive games through the power of code and imagination! 💻✨ Here’s a quick look at my Dice Minesweeper Game: https://lnkd.in/gjbqMVdz #WebDevelopment #HTML #CSS #JavaScript #FrontendDevelopment #CodingJourney #30DaysOfCode #GameDevelopment #InteractiveProjects #CreativeCoding #FunWithCode #LearningByBuilding
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