diff --git a/source/_posts/react.md b/source/_posts/react.md
index 7743c74..db3c2d0 100644
--- a/source/_posts/react.md
+++ b/source/_posts/react.md
@@ -382,4 +382,189 @@ export default function Weather(props) {
}
}
```
-Note: Make sure to import Axios first to your project.
\ No newline at end of file
+Note: Make sure to import Axios first to your project.
+
+
+HOOKS
+------------
+
+### useState Hook
+
+```javascript
+import React, { useState } from "react";
+
+function Counter() {
+ const [count, setCount] = useState(0);
+
+ return (
+
+
Count: {count}
+
+
+ );
+}
+
+export default Counter;
+```
+Note: The useState Hook is a built-in React Hook that allows functional components to manage local state. It provides a way to declare state variables and update them within a functional component.
+Example code illustrating how to use it
+
+
+### Multiple State Variable Declaration
+
+```javascript
+import React, { useState } from "react";
+
+function Counter() {
+ const [count, setCount] = useState(0);
+ const [name, setName] = useState("");
+ const [isCompleted, setIsCompleted] = useState(false);
+
+ const handleIncrement = () => {
+ setCount(count + 1);
+ };
+
+ const handleNameChange = (event) => {
+ setName(event.target.value);
+ };
+
+ const toggleCompletion = () => {
+ setIsCompleted(!isCompleted);
+ };
+
+ return (
+
+
Count: {count}
+
+
+
+
+
+
+ );
+}
+
+export default Counter;
+```
+Note: You can declare multiple state variables using the useState Hook by calling it multiple times in a functional component. Each call to useState manages a separate piece of state.
+
+### Input State Management
+
+```javascript
+import { useState } from "react";
+
+function FormExample() {
+ const [formData, setFormData] = useState({name: "",email: "",message: ""});
+
+ const handleChange = (event) => {
+ const { name, value } = event.target;
+ setFormData((prevFormData) => ({ ...prevFormData, [name]: value }));
+ };
+
+ const handleSubmit = (event) => {
+ event.preventDefault();
+ alert(`Name: ${formData.name}, Email: ${formData.email}, Message: ${formData.message}`
+ );
+};
+
+ return (
+
+ );
+}
+
+export default FormExample;
+```
+
+### useEffect Hook
+
+```javascript
+import React, { useState, useEffect } from "react";
+
+function Timer() {
+ const [seconds, setSeconds] = useState(0);
+
+ useEffect(() => {
+ const interval = setInterval(() => {
+ setSeconds((prevSeconds) => prevSeconds + 1);
+ }, 1000);
+
+ return () => clearInterval(interval);
+ }, []);
+
+ return
Seconds: {seconds}
;
+}
+
+export default Timer;
+```
+Note: The useEffect Hook in React is used for performing side effects in functional components. It allows you to execute code based on component lifecycle events like mounting, updating, and unmounting.
+
+### Fetch API using useEffect
+
+```javascript
+import React, { useState, useEffect } from "react";
+import axios from "axios";
+
+function UserList() {
+ const [users, setUsers] = useState([]);
+
+ useEffect(() => {
+ axios.get("https://jsonplaceholder.typicode.com/users")
+ .then(response => {
+ setUsers(response.data);
+ })
+ .catch(error => {
+ console.error("Error fetching users:", error);
+ });
+ }, []);
+
+ return (
+
+
User List
+
+ {users.map(user => (
+
{user.name}
+ ))}
+
+
+ );
+}
+
+export default UserList;
+```
+Note: Make sure to import Axios first to your project.
+
+### Custom Hook creation useLocalStorage
+
+```javascript
+import { useState, useEffect } from "react";
+
+function useLocalStorage(key, initialValue) {
+ const [value, setValue] = useState(() => {
+ const storedValue = localStorage.getItem(key);
+ return storedValue !== null ? JSON.parse(storedValue) : initialValue;
+ });
+
+ useEffect(() => {
+ localStorage.setItem(key, JSON.stringify(value));
+ }, [key, value]);
+
+ return [value, setValue];
+}
+
+export default useLocalStorage;
+```
+Note: Custom Hooks are reusable functions in React that contain logic shared across multiple components. They allow you to extract stateful logic from components into standalone functions.
\ No newline at end of file