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.
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.
Before the introduction of Hooks, we can only use state within Class components.
We can not use Function components for state management.
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.
Let us practice Hooks with an example provided by React.js documentation.
#programming #react-native #web-development #react #javascript