Answers for "firebase db react"

7

firebase react js

npm install firebase
Posted by: Guest on July-31-2020
0

using firebase with react key value

componentDidMount() {
  const itemsRef = firebase.database().ref('items');
  itemsRef.on('value', (snapshot) => {
    let items = snapshot.val();
    let newState = [];
    for (let item in items) {
      newState.push({
        id: item,
        title: items[item].title,
        user: items[item].user
      });
    }
    this.setState({
      items: newState
    });
  });
}
Posted by: Guest on July-29-2020

Browse Popular Code Answers by Language