shlogg · Early preview
Joodi @miladjoodi

Optimize React Apps With UseCallback For Better Performance

useCallback to the rescue! Saved me from unnecessary re-renders & UI issues. Now my routing works smoothly & code looks cleaner. One of those hooks that feels like magic once you get it

Hey there, devs! 👋
Today, I stumbled upon something that absolutely blew my mind: useCallback. It's a game-changer in React, and I can’t wait to share how it saved me from a frustrating issue and made my code so much better. Let me walk you through my little adventure! 🚀



  
  
  The Problem 🧐

I had this function for handling submenu clicks:

const handleSubmenuClick = (submenuName: string) => {
  switch (submenuName) {
    case "add_user":
      router.push("/manage/users/add");
      break;
    case "update_user":
      if (!user_id) {
        alert("Please Select One Atleast!");...