debug icon indicating copy to clipboard operation
debug copied to clipboard

Does debug support React Native remote debugging.

Open ArvoGuo opened this issue 6 years ago • 6 comments

Should I set other extra parameters, I didn't see any output

import {AppRegistry, Platform} from 'react-native';
import debug from 'debug';
const logger = debug('Test');
logger('test')

ArvoGuo avatar Feb 18 '19 10:02 ArvoGuo

@ArvoGuo try adding debug.enable("*") before logger('test')

maxkomarychev avatar Feb 20 '19 07:02 maxkomarychev

I want to leave this open for the 5.x release because I get a lot of React Native questions and haven't used it myself. I want to investigate having some better support.

Qix- avatar Mar 07 '19 14:03 Qix-

@maxkomarychev - can you confirm why that works (I did not see it in the readme, although I guess this is being improved for v5). Using debug 4.10.0

The reason I'm asking is that in react-native 0.58.6 (using react 16.6.3) it was working ok without it, but when upgrading to react-native 0.59.8 (using react 16.8.3) it started working only when adding debug.enable("*").

jacquesdev avatar Jun 03 '19 10:06 jacquesdev

1 year late, but updating for anyone who references this.

This is the intended behaviour of metro creating an isolated environment. Refer to packages such as dotenv for how to pass environment variables to react native.

Also note that debug.enable(DEBUG) only needs to be set once, ideally in App.tsx

xyz-tw avatar Jul 07 '20 04:07 xyz-tw

@Qix- React Native has AsyncStorage instead of localStorage. As the name suggests, it's async, promise based. From scanning the code it seems like debug expects storage.getItem() to return synchronously. If you're interested in adding support for React Native in future versions, adding support for AsyncStorage.getItem() as a fallback to localStorage.getItem() would be one way to go. If you need any support with this approach, feel free to ping me and I'll try to help out if I can.

chmac avatar Dec 01 '20 17:12 chmac

Workaround was posted here: https://github.com/debug-js/debug/issues/640#issuecomment-441263230

ghoshabhi avatar Feb 17 '22 00:02 ghoshabhi