class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(error) {
// Update state so the next render will show the fallback UI.
return { hasError: true };
}
I am not getting how return statement is changing the state if we can't change state without this.setState() method?
Aucun commentaire:
Enregistrer un commentaire