Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- constructor() {
- super();
- this.unsubscribe = null;
- this.ref = firebase.firestore().collection("termins");
- }
- state = {
- snapshots: [],
- loading: true
- };
- componentDidMount() {
- this.unsubscribe = this.ref.onSnapshot(this.onCollectionUpdate)
- }
- componentWillUnmount() {
- this.unsubscribe();
- }
- onCollectionUpdate = (querySnapshot) => {
- const todos = [];
- querySnapshot.forEach((doc) => {
- const { time, salonname } = doc.data();
- todos.push({
- key: doc.id,
- doc, // DocumentSnapshot
- time,
- salonname,
- });
- });
- this.setState({
- todos,
- loading: false,
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement