Created
January 30, 2017 12:19
-
-
Save ptomasroos/9cd64ad6513fca9ae170028ecbbd7ffd to your computer and use it in GitHub Desktop.
Prevent slow console logging in RN production apps
This file contains 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
// this guards against console usage in production builds since | |
// babel transform of remove console won't work with react-native preset | |
if (!__DEV__) { | |
['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', | |
'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'profile', 'profileEnd', | |
'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'].forEach( | |
(methodName) => { | |
console[methodName] = () => { /* noop */ }; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment