LogBox is a development tool that displays logs in your app during development. It replaces the older YellowBox and RedBox error screens.
LogBox is only active in development mode (
__DEV__ === true). In production builds, all LogBox methods are no-ops.Methods
install()
uninstall()
isInstalled()
trueif LogBox is installed,falseotherwise
ignoreLogs()
patterns: Array of strings or RegExp patterns to ignore
ignoreAllLogs()
value: Whether to ignore all logs (defaults totrueif not provided)
clearAllLogs()
addLog()
log: Log data object containing:level:'warn'|'error'|'fatal'message: Message object withcontentstringcategory: String category for groupingcomponentStack: Stack trace array
addException()
error: Extended exception data object
Common Patterns
Ignore Known Third-Party Warnings
Conditional LogBox Configuration
Clear Logs Programmatically
Project Setup Example
Development vs Production
Development (__DEV__ === true):
- LogBox intercepts
console.warn()andconsole.error() - Shows warnings and errors in an overlay
- Allows ignoring specific messages
__DEV__ === false):
- All LogBox methods become no-ops
- No overlays are shown
- Console methods work normally
- No performance impact
Best Practices
-
Don’t Ignore Everything: Use
ignoreLogs()sparingly and only for known, unavoidable warnings -
Use Specific Patterns: Prefer specific strings over broad regex patterns to avoid hiding important warnings
-
Document Ignored Warnings: Add comments explaining why each warning is ignored
- Temporary Ignores: Review ignored warnings periodically and remove them when the underlying issues are fixed
- Team Communication: Keep ignored warnings in version control so the whole team is aware