Made sure that we don't try to fetch IDs that aren't in the database.
This commit is contained in:
parent
74cd0ec307
commit
e792bb3483
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue