You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-14Lines changed: 11 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -6402,25 +6402,20 @@ Learn to code and get hired with <a href="https://zerotomastery.io/?utm_source=g
6402
6402
6403
6403
303. ### How to fetch data with React Hooks?
6404
6404
6405
-
The effect hook called `useEffect`is used to fetch the data with axios from the API and to set the data in the local state of the component with the state hook’s update function.
6405
+
The effect hook called `useEffect`can be used to fetch data from an API and to set the data in the local state of the component with the useState hook’s update function.
6406
6406
6407
-
Let's take an example in which it fetches list of react articles from the API
6407
+
Here is an example of fetching a list of react articles from an API using fetch.
@@ -6437,7 +6432,9 @@ Learn to code and get hired with <a href="https://zerotomastery.io/?utm_source=g
6437
6432
exportdefaultApp;
6438
6433
```
6439
6434
6440
-
Remember we provided an empty array as second argument to the effect hook to avoid activating it on component updates but only on mounting of the component. i.e, It fetches only on component mount.
6435
+
A popular way to simplify this is by using the library axios.
6436
+
6437
+
We provided an empty array as second argument to the useEffect hook to avoid activating it on component updates. This way, it only fetches on component mount.
0 commit comments