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

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