DEV Community

loading...
Cover image for What and Why of React Hooks?

What and Why of React Hooks?

Sachin Chaurasiya
A passionate developer who love to connect with people to share ideas and knowledge.
Originally published at sachinchaurasiya.hashnode.dev Updated on ・1 min read

Hello Learners,
From today onwards I am going to share some information about React hooks. #8DaysOfReactHook

So this is the #1stDayOfReactHook and in this post, I have discussed what and why of React Hooks. also, what are the different types of the hook?.

What are Hooks?

Hooks were introduced in React version 16.8. Hooks are functions that help us to manage State and mimic lifecycle feature from a functional component.

Why Hooks?

Previously Functional Components were called Stateless and only class components were used for state management and lifecycle methods. if we want to manage some state we have to convert the functional component to class component this led us to the development of the hook.

Do's and Don'ts of Hooks

  • Call hooks from the functional component
  • Don't call hooks from the class component.
  • Don't call hooks from loops and nested function.

Different types of hooks

  • useState
  • useEffect
  • useRef
  • useContext
  • useReducer
  • useCallback
  • useMemo

From the next day will break down each hook one by one, so stay connected.

If I have missed 😀something please let me know in the comment section

Thank You 😊 For Reading.

Discussion (0)