React
Basic Usage
Learn how to use the core features of the Traque React SDK
Basic Usage
The Traque React SDK provides several core features for error tracking and monitoring in your React applications. This guide covers the main components and hooks you'll use most frequently.
Error Boundaries
Error Boundaries are React components that catch JavaScript errors anywhere in their child component tree. The Traque SDK provides an ErrorBoundary
component that automatically reports these errors to your Traque service.
Basic Error Boundary Usage
Advanced Error Boundary Configuration
You can customize the error handling and display:
Manual Error Reporting
The useTraque
hook provides access to error reporting functions for manual error capture.
Using the useTraque Hook
Adding Context to Errors
You can add additional context when capturing errors:
Accessing the Traque Instance
You can access the Traque instance directly using the useTraque
hook:
Best Practices
- Place Error Boundaries strategically to isolate failures to specific components
- Add meaningful context when capturing errors manually
- Use appropriate error severity levels
- Include relevant user and system information
- Handle async errors appropriately