Created
September 28, 2018 04:53
-
-
Save rrrhys/07f7f46278375d897f3880868e82d9b5 to your computer and use it in GitHub Desktop.
Check if the debugger is attached in a React Native project.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// setTimeout (and other wait related code) fails when a debugger is attached to React Native. | |
// in DebuggerCheck.ts | |
let _looksLikeDebuggerAttached = true; | |
setTimeout(() => { | |
_looksLikeDebuggerAttached = false; | |
}, 1); | |
export default { | |
debuggerIsAttached: () => { | |
return _looksLikeDebuggerAttached; | |
} | |
} | |
// end DebuggerCheck.ts | |
//---- | |
// how to use: | |
import DebuggerCheck from './DebuggerCheck'; | |
if(DebuggerCheck.debuggerIsAttached()){ | |
// handle settimeout differently etc | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment