import React, { useEffect, useState } from "react"; import "./App.css"; import { Exceptionless, ExceptionlessErrorBoundary, } from "@exceptionless/react"; const HooksExampleApp = () => { const [error, setError] = useState(false); useEffect(() => { startExceptionless(); }, []); const startExceptionless = async () => { await Exceptionless.startup((c) => { c.apiKey = "LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw"; c.serverUrl = "http://localhost:5000"; c.useDebugLogger(); c.defaultTags.push("Example", "React"); }); }; const throwErrorInComponent = () => { setError(true); }; const submitMessage = () => { Exceptionless.submitLog("Hello, world!"); }; const tryCatchExample = () => { try { throw new Error("Caught in the try/catch"); } catch (error) { Exceptionless.submitException(error); } }; const renderExample = () => { if (error) { throw new Error("I crashed!"); } else { return (

Exceptionless React Sample

By pressing the button below, an uncaught error will be thrown inside your component. This will automatically be sent to Exceptionless.

The following buttons simulated handled events outside the component.

); } }; return ( {renderExample()} ); }; export default HooksExampleApp;