-
Notifications
You must be signed in to change notification settings - Fork 0
/
Viewpdf.js
41 lines (38 loc) · 921 Bytes
/
Viewpdf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React, { useEffect, useState } from 'react'
import db from './firebase';
import './Viewpdf.css'
import { Link } from 'react-router-dom';
import Pdfcard from './Pdfcard';
function Viewpdf() {
const [pdfs,setpdfs] = useState([''])
useEffect(()=>{
getpdfs();
},[]);
function getpdfs(){
db.collection('pdfs').onSnapshot(function(querySnapshot){
setpdfs(
querySnapshot.docs.map((doc)=>({
id:doc.id,
name:doc.data().pdfname,
pdf:doc.data().pdf,
}))
);
});
console.log(pdfs)
}
return (
<div className='viewpdf'>
<div className='pdfcoun'>
<p>Total pdf:{pdfs.length}</p>
</div>
<div className='viewpdf1'>
{
pdfs.map((pdf)=>(
<Pdfcard id={pdf.id} name={pdf.name} pdf={pdf.pdf}/>
))
}
</div>
</div>
)
}
export default Viewpdf