Timeline for React API call outside useEffect
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 14, 2020 at 7:44 | comment | added | waqas Mumtaz | Yes for onClick, it's fine because you make every call when user click on button. But for initial fetching, if you move your code from use effect to outside, it will run infinitely | |
Feb 14, 2020 at 7:40 | review | Close votes | |||
Feb 18, 2020 at 0:00 | |||||
Feb 14, 2020 at 7:34 | vote | accept | visizky | ||
Feb 14, 2020 at 7:24 | answer | added | Siraj Alam | timeline score: 7 | |
Feb 14, 2020 at 7:23 | comment | added | visizky | I checked the network tab and it just calls one API for each onClick callback | |
Feb 14, 2020 at 7:23 | answer | added | Muhammad Zeeshan | timeline score: 2 | |
Feb 14, 2020 at 7:23 | answer | added | PrakashT | timeline score: 2 | |
Feb 14, 2020 at 7:22 | comment | added | waqas Mumtaz | NO, If you do so, your api call will run as infinite loop. Test it and check the network tab | |
Feb 14, 2020 at 7:18 | history | asked | visizky | CC BY-SA 4.0 |