debug
debug copied to clipboard
Does debug support React Native remote debugging.
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 try adding debug.enable("*")
before logger('test')
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.
@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("*")
.
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
@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.
Workaround was posted here: https://github.com/debug-js/debug/issues/640#issuecomment-441263230