Made sure that we don't try to fetch IDs that aren't in the database.

This commit is contained in:
wildscotsmen 2018-10-08 00:47:24 -04:00
parent 74cd0ec307
commit e792bb3483
1 changed files with 7 additions and 1 deletions

View File

@ -121,7 +121,7 @@ const styles = theme => ({
class ViewSightings extends React.Component {
constructor(props){
super(props);
super(props);
this.handleSubmit = this.handleSubmit.bind(this);
}
@ -154,7 +154,13 @@ class ViewSightings extends React.Component {
e.preventDefault();
const itemSighting = firebase.database().ref("sightings/" + this.state.id);
itemSighting.once("value").then((snapshot) => {
// Die if there's no data for that ID.
if (!snapshot.exists()) {
return;
}
let data = snapshot.val();
this.setState({
date: data.date,
time: data.time,