Created
September 29, 2018 19:10
-
-
Save dance2die/ebff548c1c4253f5c14349b3d6004a72 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App extends React.Component { | |
state = { | |
errorBoundaryKey: 0 | |
}; | |
handleRerenderButtonClick = () => this.forceUpdate(); | |
handleResetButtonClick = () => | |
this.setState(prevState => ({ | |
errorBoundaryKey: prevState.errorBoundaryKey + 1 | |
})); | |
render() { | |
return ( | |
<div className="App"> | |
<button onClick={this.handleRerenderButtonClick}>re-render</button> | |
<button onClick={this.handleResetButtonClick}> | |
reset error boundary | |
</button> | |
<ErrorBoundary key={this.state.errorBoundaryKey}> | |
<ComponentThatMayError /> | |
</ErrorBoundary> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment