Home > Back-end >  Parsing error: Unexpected token, expected "," react
Parsing error: Unexpected token, expected "," react

Time:11-14

Parsing error: Unexpected token, expected ","

13 | setPosts(snapshot.docs.map((doc)=>({id: doc.id, data: doc.data() }))) 14 | )

15 | },[]); | ^ 16 | 17 | return ( 18 |

 useEffect(() =>{
 db.collection['posts'].onSnapshot(snapshot =>(
 setPosts(snapshot.docs.map((doc)=>({id: doc.id, data: doc.data() })))
  )
 },[]);

CodePudding user response:

useEffect(() => {
    db.collection['posts'].onSnapshot(snapshot => (
        setPosts(snapshot.docs.map((doc) => ({ id: doc.id, data: doc.data() })))
    ));
}, []);
  • Related