Last active
July 6, 2018 02:03
-
-
Save loraxx753/f9796eb8943e47d04d86b24bab65b0af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import SearchBar from "./SearchBar"; | |
import AddImageForm from "./AddImageForm"; | |
import Images from "./Images"; | |
import firebase from "../firebase"; | |
const itemsRef = firebase.database().ref("images"); | |
class Archive extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { images: [] }; | |
} | |
/** | |
* This is where you can update your state each time the component is "mounted" / initially loaded. | |
*/ | |
componentWillMount() { | |
itemsRef.on("value", snapshot => { | |
const lessAwkardThisWay = snapshot.val(); | |
this.setState({ | |
images: [ ...lessAwkardThisWay ] | |
}) | |
}) | |
} | |
render() { | |
return ( | |
<div> | |
<h1>This is the Archive</h1> | |
<SearchBar /> | |
<AddImageForm /> | |
<Images images={this.state.images} /> | |
</div> | |
); | |
} | |
} | |
export default Archive; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment