using firebase with react key value

Solutions on MaxInterview for using firebase with react key value by the best coders in the world

showing results for - "using firebase with react key value"
Dario
29 Sep 2018
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}