I wanted an easier way to format debug data for Reactotron that would render more easily, so I came up with this code snippet:
if (__DEV__) {
console.tlog = (name, mainVal, ...otherVals) => {
let vars = {_name: name, ...otherVals}
if (typeof mainVal === 'object') {
vars = {...vars, ...mainVal}
} else {
vars['_mainVal'] = mainVal
}
Reactotron.display({
name: 'APP DEBUG',
preview: name,
value: vars
})
}
} else {
console.tlog = () => false
}
This lets me call it in a couple of different ways depending on what i need to show:
console.tlog('i got some data!', dataValue)
or
console.tlog('i got a bunch of data!', {dataBit1: somethingSomething, dataBit2: somethingElseSomething}
or in a few cases:
console.tlog('i got a bunch of data but one main bit!', theMainSomething, {otherBit11: somethingSomething, otherBit2: somethingElseSomething}