So the onboarding friction that doesn't go away. Like whenever someone gets into a new code base, the initial learning curve is normal. But we go to that senior person who is there to ask about the code base. And yeah, now we have AI also. But yeah, that's there. But if it keeps on happening over and over again, over time, then we need to have something that explains the business logic to us. There should be a system that explains the business logic to us. And if you're that senior who helps out the juniors, you know, in any issues, my respect for you. And yeah, when you have your own state management tool, when you choose to, you know, build your own stuff, your own things, then in that case, the React dev tools or some developer tools have no visibility over it. So we should invest in developing our custom dev tools there.
Then now we'll see how a React dev tools is actually built, right? So once you look at this scary diagram, I'm not going to explain you this deep React internal and all, but I strongly recommend pause here, take time to understand what's happening over here. But this mechanism React exposes for this is actually very simple. I'll tell you with the much simplified, you know, architecture. Then we'll look into the code of how I did it. So when your React app starts up before anything renders, it checks for a global variable on the window. And it is called react dev tools global hook. Yeah, React uses it as a communication channel. So every commit, every update, whatever you do, you know, every state changes, everything reacts actually streams this information through this hook only. And this is how the official React dev tools extension also works.
So they are pumped into an extension. And once you are in your dev tools, you will see a new, you know, new thing, a new panel called whatever they have, like they have components, they have profiler and a lot of Yeah, now here's the part that opens the door for us. This hook is not just an object on a window. There's nothing special about it, who puts it there, we can put our own listener on to it. That's that's a great part. So alongside the official dev tools, we work with React and not around it. So this architecture has four pieces basically. So we build our own custom inspector extension, we have our own logic there. Then in our UI, I'll see we'll see what this whatever we have built like yeah. So let's see how we can build this custom UI. Dev tools, I'll show you my code.
Comments