React Builtin Hooks
+React Builtin Hooks
+What is a State?
+useState()
+Side Effects
+useEffect
+
+ {`
+ useEffect(() => {
+ document.title = "Hey There, I'm from useEffect"
+ })
+ `}
+
+ useEffect
+
+ {`
+ useEffect(() => {
+ document.title = "Hey There, I'm from useEffect"
+ }) ← No Arguments means this will be called each time
+ this component re-renders
+ `}
+
+ useEffect
+
+ {`
+ useEffect(() => {
+ document.title = "Hey There, I'm from useEffect"
+ }, []) ← An empty array as an argument will run the
+ effect once the component is mounted
+ `}
+
+ useEffect
+
+ {`
+ useEffect(() => {
+ document.title = "Hey There, I'm from useEffect"
+ }, [prop1]) ← We can pass value
+ `}
+
+ useEffect
+
+ {`
+ useEffect(() => {
+ document.title = "Hey There, I'm from useEffect"
+ }, [prop1, state1]) ← Actually we can pass multiple-values
+ `}
+
+ useEffect
+
+ {`
+ useEffect(() => {
+ document.title = "Hey There, I'm from useEffect"
+ }, [prop1, state1]) ← This is called dependency list
+ `}
+
+ useEffect
+
+ {`
+ useEffect(() => {
+ document.title = "Hey There, I'm from useEffect"
+ }, [prop1, state1]) ← Effect will run whenever any
+ of the values on dependency list changes
+ `}
+
+ useEffect
+
+ {`
+ useEffect(() => {
+ document.title = "Hey There, I'm from useEffect";
+
+ return () => {
+ // Clean Up function 🧹
+ }
+ }, [prop1, state1]);
+ `}
+
+