I've been using the react-devtools to detect any unnecessary component updates, however I'm not sure I fully understand how it works.
I can identify the various components that got updated by the added borders indicating that they got updated but I'm not sure what the various colors of those borders mean (I've so far seen cyan and light green colors).
React Developer Tools is a Chrome DevTools extension for the open-source React JavaScript library. It allows you to inspect the React component hierarchies in the Chrome Developer Tools. You will get two new tabs in your Chrome DevTools: "⚛️ Components" and "⚛️ Profiler".
Access React components and state from the console Select a component in React DevTools and pop open the console (hitting the Esc key lets you see both at once). Type in $r and you'll have access to the instance of that React component from the console.
Use React developer tools in Chrome By selecting one of the components in the tree, you can inspect and edit its current props and state in the panel on the right. In the breadcrumbs you can inspect the selected component, the component that created it, the component that created that one, and so on.
I'm not familiar with this either, but I'll trace through the code! :)
This is the component that renders the "Highlight Updates" toggle. It calls a changeTraceUpdates
method in the main Store
which sends a message through the "bridge" to activate the TraceUpdatesBackendManager
. Poking around that file, we see a couple of classes with names like "presenter" in them; I assume one of these is what actually draws the border. In particular, TraceUpdatesWebNodePresenter
looks related because it defines an array of COLORS
. It looks like these colors are chosen based on a "hit" attribute, which a quick search suggests is set by TraceUpdatesAbstractNodePresenter
– and gets incremented each time an element is "presented".
Reading between the lines then, I assume this means that components that render less frequently will be outlined with "cool" colors (blue) and ones that render more frequently will be outlined with "hot" colors (red).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With