react catch error in component
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
componentDidCatch(error, info) { // Display fallback UI this.setState({ hasError: true }); // You can also log the error to an error reporting service logErrorToMyService(error, info); }
render() {
if (this.state.hasError) { // You can render any custom fallback UI return <h1>Something went wrong.</h1>; } return this.props.children;
}
}
Also in JavaScript:
- node js split
- open another page js
- linking a script .js
- knex insert multiple rows
- cypress click
- Javascript check for hash in URL
- how to update node
- javascript is undefined
- javascript random rgb
- javascript array find highest value of array of objects by key
- javascript convert comma separated string to array
- lodash remove multiple items from array
- vuejs router params
- Beginning Node.js
- uuid v4 react
- jquery close another dialog
- string to JSONobject + android
- import npm module node.js
- in object transform translate property concat with rotate value angular 7
- javasript array indexof
- axios set authorization header
- kb to mb js
- scroll jquery to anchor
- focus on input field vuejs event