React Hooks Tutorial - 6 - Fetching data with useEffect

preview_player
Показать описание
React Hooks are revolutionising the way we develop in React and solving some of our biggest concerns. The useEffect Hook allows us to replace repetitive component lifecycle code.

Essentially, a Hook is a special function that allows you to “hook into” React features. Hooks are a great solution if you’ve previously written a functional component and realize that you need to add state to it.

In this example we are explaining how to use useEffect as componentDidMount

When the user lands on our page, we want to call the API. In other words, we want to call the API during the mounting part of the component's lifecycle.

Then, let's create an asynchronous function to fetch our data. An asynchronous function is a function that needs to wait after the promise is resolved before continuing. In our case, the function will need to wait after the data is fetched (our promise) before continuing.
The function we just created is wrapped in a try...catch statement so that the function catches the errors and prints them in the console. This helps debug and prevents the app to crash unexpectedly.

React Native | React Native tutorial | React Native app | React Native tutorial for beginners | React Native crash course | React Native project | React Native app tutorial | React | mobile app development | tutorial | React Native for beginners | app development | React-Native | programming | React Native course | learn React Native | React Native 2020 | learn React | ReactNative | React Native mobile app | React Native full course | React Native hooks | React Native ui design | React Native ui | React tutorial | React vs React Native | beginners | javascript | React Native live coding | React-Native tutorial | React Native project tutorial | React Native tutorials for beginners | mobile development | what is React Native | React native app | React Native navigation | React Native list | React navigation | React Native projects for beginners | set up React Native | design to React Native | React Native code | adding font to React Native | React Native project setup | build an app | learn app development | let's code React Native | install React Native | React Native setup | React Native vs code | React Native introduction | React Native windows | javascript mobile app | React Native basics | React Native beginner tutorial | why learn React Native | what is React Native used for | why React Native | why React Native is not garbage | introduction to React Native | create React Native app | React Native forms | React Native app build | React Native beginner | intro to React Native | React Native scrollview | React Native scroll view | React Native flat list | Flatlist React Native | flat list component | React Native lists | React Native useState | React Native text input | React text input | React Native animated splash screen | React Native animatable | React Native login signup and navigation example | React Native login screen | React Native linear gradient tutorial | React Native splash screen | React Native splash screen animation | login & signup ui in React Native | login and signup screen in React Native | React Native linear gradient | beginner app | drawer navigator | drawer navigation | stack navigation | app build | React app | React navigator | scroll view | React list | list data
Рекомендации по теме