reactotron icon indicating copy to clipboard operation
reactotron copied to clipboard

console.tron "tip" is error-prone

Open danikenan opened this issue 9 years ago • 4 comments

Your "tip" recommends declaring console.tron = Reactotron

Then calling console.tron.log('Sweet Freedom!')

But we (and I think so should everybody) do not import nor configure Reactotron in non __DEV__ environments. This means that console.tron is not available at all (and/or Reactotron).

In this case the result of calling

console.tron.log('RED BOX') is a red box, certainly not 'Sweet Freedom!'

danikenan avatar May 13 '17 02:05 danikenan

Mocking an interface to console.tron can help here, but I recommend not leaving log statement in.

I'm with you in wanting to leave it out in production builds though.

skellock avatar May 13 '17 11:05 skellock

Leaving console.log might not be 'nice', but leaving console.troncauses a crash.

Also, even when using transformers like babel-plugin-console-log, you do not get automatic support for console.tron.* removal. At best you need to use a configurable plugin and configure it manually.

I think the least you need to do is to mention this right next to the 'tip'.

Your tool is great and impressive. Why not keep it that way and remove any might-be-pitfalls from the docs?

danikenan avatar May 13 '17 11:05 danikenan

Thanks. And ya, you're right. I will update the docs.

I wonder if babel-plugin-transform-remove-console would help here? I'll give that a shot.

skellock avatar May 13 '17 14:05 skellock

Thanks for the good conversation. Moving this over to https://github.com/infinitered/reactotron/issues/433 to try to get a solution in place.

skellock avatar May 20 '17 14:05 skellock