It's was a real helpful video on the whole for me as a react learner,but i have a question, why don't you use a single map function just inside the div and use anyother response value for key and display the name than having a two map function one inside the useeffect and other in div, if i am wrong pls correct me
Hi, thank you! No reason really, just haven't thought about it. So I will agree with you that just set planets array as data would be a better choice, since then you can choose what to visualise when the "requirements" change. Also note that there is no reason for using useEffect at all, and better to fetch data in event handler. Also like @Famouzi has mentioned it, would not be a bad idea to consider using debounce so that we do not make fetch requests unnecessarily when user rapidly clicks counter.
I have mentioned in the description that using useEffect is unnecessary. I have left it there since I have written that out of habit, on a impulse and intentionally kept editing to a minimum. But, yes, we can just fetch in event handler. Talking about debounce for this case or at least mentioning during interview is a great idea.
Thanks, man! Very useful content 🙌
Glad it was helpful! 🙌
It's was a real helpful video on the whole for me as a react learner,but i have a question, why don't you use a single map function just inside the div and use anyother response value for key and display the name than having a two map function one inside the useeffect and other in div, if i am wrong pls correct me
Hi, thank you! No reason really, just haven't thought about it. So I will agree with you that just set planets array as data would be a better choice, since then you can choose what to visualise when the "requirements" change. Also note that there is no reason for using useEffect at all, and better to fetch data in event handler. Also like @Famouzi has mentioned it, would not be a bad idea to consider using debounce so that we do not make fetch requests unnecessarily when user rapidly clicks counter.
Why don't you just put fetch inside event handler after click? Also adding debounce could be helpful here
I have mentioned in the description that using useEffect is unnecessary. I have left it there since I have written that out of habit, on a impulse and intentionally kept editing to a minimum. But, yes, we can just fetch in event handler. Talking about debounce for this case or at least mentioning during interview is a great idea.