Skip to content
This repository has been archived by the owner on Jun 3, 2018. It is now read-only.

Commit

Permalink
Prototype error handling modal
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmartinelli committed Apr 10, 2016
1 parent 14491ff commit b13ab81
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,50 @@ import {Database} from './database.js';
import React from 'react';
import ReactDOM from 'react-dom';
import {Mediator} from 'mediator-js';
import Modal from 'react-modal';
import Codemirror from 'react-codemirror';


class App extends React.Component {
constructor() {
super();
this.db = new Database();
this.closeErrorModal = this.closeErrorModal.bind(this);
this.state = {
errorMessage: '',
showError: false
};
}

componentDidMount() {
var self = this;
window.onerror = function(message, source, lineno, colno, error) {
self.setState({
errorMessage: message,
showErrorModal: true
});
}
}

closeErrorModal() {
this.setState({
showErrorModal: false
});
}

render() {
return <div className="app">
<Toolbar db={this.db} />
<Map />
<Editor db={this.db} />
<Modal
isOpen={this.state.showErrorModal}
className="dark-modal"
overlayClassName="dark-overlay"
>
<p>{this.state.errorMessage}</p>
<button onClick={this.closeErrorModal}>Close Modal...</button>
</Modal>
</div>;
}
}
Expand Down

0 comments on commit b13ab81

Please sign in to comment.