showing results for - "recieve data from firebase database"
Brandon
13 Sep 2020
1const [rooms, setRooms] = useState([]);
2
3useEffect(() => {
4	const getRooms = db.collection('rooms').onSnapshot((snapshot) => {
5		setRooms(
6			snapshot.docs.map((doc) => {
7				return { id: doc.id, data: doc.data() };
8			})
9		);
10	});
11		return () => {
12		getRooms();
13	};
14}, []);