react hooks
Basic React Hooks
· ☕ 3 min read
React Hooks are a powerful feature in React that allow developers to use state and other React features in functional components, instead of relying solely on class components. Hooks were introduced in React 16.8 and have quickly become a popular way to write reusable and easy-to-read code. In this post, we’ll explore the basics of React Hooks and learn how to use them in your applications. What are React Hooks? React Hooks are functions that allow you to use React features in functional components.

Our First Custom React Hook
· ☕ 2 min read
In this article, we will learn how to create a very simple custom React hook. For simplicity sake, the only thing the hook will do is to show an alert message when a button is clicked. In a nutshell, creating a custom hook is as simple creating a function, calling which returns something. This function, by convention, starts with use and we will call it useAlert. 1 2 3 const useAlert = () => { // return something } The hook has to return something which can be a function, an array, an object, or even a primitive values.