对使用中的异步功能的React Hook警告

const fetchAPIDataCountries = async () => {
    try {
        const response = await 
        axios.get('https://covid19.mathdro.id/api/countries');
        const { data } = response
        const { countries } = data
        const newData = _.map(countries, item => ({ name: item.name }))
        console.log("fetchCountries -> newData", countries)
        return newData
    } catch (error) {
        return error;
    }
}
useEffect(() => {
  const fetchAPI = async () => {
   let dataCountries = await fetchAPIDataCountries();
   setCountries(dataCountries)`enter code here`;
  };
  return () => fetchAPI();
 }, []);

i didn't get data from api but i try remove return() in useEffect() just wrote fetchAPI(), It 's ok. I don't know what happen here, can anyone explain it.Thank you.

评论