MCPcopy Create free account
hub / github.com/CodeWithHarry/Sigma-Web-Dev-Course / Navbar

Function Navbar

Video 108/src/components/Navbar.jsx:3–33  ·  view source on GitHub ↗
({ color })

Source from the content-addressed store, hash-verified

1import React, { useEffect } from 'react'
2
3const Navbar = ({ color }) => {
4 // Case 1: Run on every render
5 useEffect(() => {
6 alert("Hey I will run on every render")
7 })
8
9 // Case 2: Run only on first render
10 useEffect(() => {
11 alert("Hey welcome to my page. This is the first render")
12 }, [])
13
14 // Case 3: Run only when certain values change
15 useEffect(() => {
16 alert("Hey I am running because color was changed")
17 }, [color])
18
19 // Example of Cleanup function
20 useEffect(() => {
21 alert("Hey welcome to my page. This is the first render of app.jsx")
22
23 return () => {
24 alert("component was unmounted")
25 }
26 }, [])
27
28 return (
29 <div>
30 I am navbar of {color} color hehe..
31 </div>
32 )
33}
34
35export default Navbar

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected