1componentDidMount() {
2 const itemsRef = firebase.database().ref('items');
3 itemsRef.on('value', (snapshot) => {
4 let items = snapshot.val();
5 let newState = [];
6 for (let item in items) {
7 newState.push({
8 id: item,
9 title: items[item].title,
10 user: items[item].user
11 });
12 }
13 this.setState({
14 items: newState
15 });
16 });
17}