We all start with writing a bunch of console.log() statements in our work-in-progress React components. But then, you find yourself tracking these guys down because it’s not great to have users see all the console logs in a production app.

Here, we’ll see that with a little structure we can start transforming a bad habit into a powerful best practice.

Log all the things or clean console in prod? Why not both?
Log all the things or clean console in prod? Why not both?

1. Our Little React Sandbox

Let’s quickly create a React app to play with, using yarn, create-react-app and Typescript:

We can now start playing around in src/App.tsx and add our usual console.log() statements.

And…

Johann-Michael Thiebaut

Somehow I can do software engineering. Lead Software Engineer at swyg.com.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store