Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class App extends React.Component {
- state = { showError: true }
- toggleError = () => {
- this.setState((prevState, props) => {
- return { showError: !prevState.showError }
- })
- };
- render() {
- return (
- <DivWithErrorHandling showError={this.state.showError}>
- <h1>Your Amazing Content</h1>
- <button onClick={this.toggleError}>
- Toggle Error
- </button>
- </DivWithErrorHandling>
- );
- }
- }
Add Comment
Please, Sign In to add comment