mercredi 18 novembre 2020

the if statement not running inside the async function

 const readersInfo = useSelector(
  (state:IRootState) => state.reader.readerinfo
);


useEffect(() => {
  dispatch(getThisReaderInfoThunk())
}, [dispatch]);


const readerInfo = readersInfo[0]


const onSubmit = async () => {

  console.log("aaabbbccc")
  const recording_data=  await onStartRecord()
console.log(recording_data) //is ok 
   if (readerInfo){

 //this part can't run
    console.log("this is path",recording_data,readerInfo.id,bookId, page)
     dispatch(postAudioRecordThunk(recording_data as string,readerInfo.id,bookId, page))
   }
}

when I called the onSubmit function, the aaabbbccc did logged, but the if statement is not running, anyone could help? thx! the readerInfo is a constant loaded by useSelector from redux which is true in this case

Aucun commentaire:

Enregistrer un commentaire