Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
how to use the template literals

I'm new to React Native, I was trying to use the template literals for my firebase update, but somehow it doesn't work. Did I used in a wrong way? here is my code:

export default function updatefriends(FriendsUID){

    const friendadd = async() =>{

        
        const Uid = firebase.auth().currentUser.uid
        const friendlist = firebase.firestore().collection('users').where(
            "UID", "==", firebase.auth().currentUser.uid).get();
            
        console.log(Uid)
        friendlist.then((querySnapshot) => 

        {querySnapshot.forEach((doc) => {doc.ref.update(

            {'FriendsList.${FriendsUID}':true})
        })
    })
    }

This line having issue:

{'FriendsList.${FriendsUID}':true})

When I push the update, it added "${FriendsUID}" into my database, instead of the actual text.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to add backticks (`) in order to use template literals. Also since this is a dynamic object key property you have to wrap it in brackets []. Finally the problematic line should be:

{ [`FriendsList.${FriendsUID}`] : true }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!