Report error from react to firebase console

Multi tool use
Multi tool use


Report error from react to firebase console



I'd like to report an error when my apps crash to firebase directly from a react app, I've have enabled client logging according to this answer.



firebase.database.enableLogging(true);



I have created a component to handle errors, like this:


import React, { Component } from 'react';

class ErrorBoundary extends Component {
constructor(props) {
super(props);
this.state = {
hasError: false
};
}

componentDidCatch(error, info) {
this.setState({
hasError: true
});
//how to log the error to firebase console?
console.error(new Error(error, info))
}

render() {
if (this.state.hasError) {
return <h1>Something went wrong.</h1>;
}
return this.props.children;
}

}

export default ErrorBoundary;



I'm wondering how can I log the error from the client?, I've read about how to do it but using nodejs but not with just plain javascript (react)



Any ideas?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

7Y8x vb BDmO74FDRfSw7zxhuvvdTmK8zVziuFgN3x,k5qLy9YzXU67Jb1Sap6zBSL0o,uvGkisnVLZ
2HsXurPKI5YDqab

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications