With React Hooks we can use state, componentDidMount, componentDidUpdate, and other React features without using Class components.

First, we talk a little bit about React Hooks, and then we will be going to implement them in React Native.

In 2018, Sophie Alpert and Dan Abramov introduced Hooks. You can watch it here. I strongly suggest watching it.

What are React Hooks?

According to reactjs.org, Hooks are functions that let you “hook into” React state and lifecycle features from function components. Hooks don’t work inside classes — they let you use React without classes.

In simple terms, React Hooks let us use State, componentDidMount, componentDidUpdate, and other React features without Class components.

Why is it necessary?

Before the introduction of Hooks, we can only use state within Class components.

We can not use Function components for state management.

Is there any advantage?

Yes, it makes code short and more readable. More importantly, we can use it inside functional components. I am going to compare later in this post.

Understanding And Practicing React Hooks

Let us practice Hooks with an example provided by React.js documentation.

#programming #react-native #web-development #react #javascript

State Management Using React Hooks in React Native
2.20 GEEK