score:2

In a typical React app where you want to set a state value from the result, you would make async calls like this within a useEffect hook and set the state value after it resolves

const [doc, setDoc] = useState()

useEffect(() => {
  returnUserData(localStorage.getItem("currentUserId")).then(result => {
    setDoc(result)
  })
}, [])

Related Query

More Query from same tag