T
16

People keep using console.log for debugging in React and it's making their code messy

Last week I spent 3 hours tracing a bug because someone left 15 console.log statements in a component instead of using React DevTools to inspect state directly, has anyone else run into this mess?
1 comments

Log in to join the discussion

Log In
1 Comment
jana_lewis16
jana_lewis1611h agoTop Commenter
Honestly just start using React DevTools more, it saved me from the same nightmare. I had a coworker who would dump 20 console logs into every file and it made debugging impossible. I made a rule for myself: if I need more than 3 console logs, I open DevTools and inspect the component directly. It shows you the state tree in real time without polluting the code. Tbh once I got used to that workflow, I barely touch console.log anymore unless its for quick one-off checks. Ngl it takes a bit of practice but the difference is huge once you get it.
6