React useEffect() hook introduction 🌟

  Рет қаралды 21,512

Bro Code

Bro Code

Күн бұрын

#react #tutorial #course
00:00:00 introduction
00:02:00 setup
00:03:25 no dependencies
00:04:50 empty dependency array
00:05:51 1 dependency
00:07:25 multiple dependencies
00:09:57 why use useEffect()?
00:11:33 example 2
00:15:51 return
00:17:31 multiple useEffect() hooks
00:18:52 conclusion
// useEffect()
// React Hook that tells React to DO THIS CODE WHEN:
// (pick one)
// This component re-renders
// This component mounts
// The state of a value changes
// useEffect(function, [dependencies])
// USES
// #1 Event Listeners
// #2 DOM manipulation
// #3 Subscriptions (real-time updates)
// #4 Fetching Data from an API
// #5 Clean up when a component unmounts

Пікірлер: 44
@BroCodez
@BroCodez 7 ай бұрын
import React, {useState, useEffect} from "react"; function MyComponent() { const [width, setWidth] = useState(window.innerWidth); const [height, setHeight] = useState(window.innerHeight); useEffect(() => { window.addEventListener("resize", handleResize); console.log("EVENT LISTENER ADDED"); return () => { window.removeEventListener("resize", handleResize); console.log("EVENT LISTENER REMOVED"); } }, []); useEffect(() => { document.title = `Size: ${width} x ${height}`; }, [width, height]); function handleResize(){ setWidth(window.innerWidth); setHeight(window.innerHeight); } return ( Window Width: {width}px Window Height: {height}px ); } export default MyComponent;
@rumanhasan27
@rumanhasan27 7 ай бұрын
@MO-vr1mw
@MO-vr1mw 7 ай бұрын
Can you do Laravel please
@elitegaming8565
@elitegaming8565 7 ай бұрын
first, Subsciber from 2 years Your Javascript and Python Course is The Best Love from India ❤❤❤❤
@dasdisdus774
@dasdisdus774 Ай бұрын
This is the only tutorial (especially useEffect) that I can easily understand than others. Thank you so much Bra Code 🙏
@karan0611
@karan0611 2 күн бұрын
bro code bro 😅
@akkun_25
@akkun_25 7 ай бұрын
I appreciate you so much bro helping us out and taking from your time to teach us coding for free and gathering money for kids from your videos all that and doing that in a fun way for viewers W man W to your parents
@arcaneacademia
@arcaneacademia 3 ай бұрын
You explain things in a simple and straightforward way.
@hananfadah
@hananfadah 6 ай бұрын
The best introduction! Thank you! 😃
@milleniummoses
@milleniummoses 19 күн бұрын
This is my fourth tutorial on this subject ad neth first one I really grasped. Thank you for your time.
@Pywyoyuyp
@Pywyoyuyp Ай бұрын
This tutorial was on point. Thx! Now I am ready for a more complex examples!
@houdariyad4889
@houdariyad4889 7 ай бұрын
Our Bro is the best as always !Appreciate ur effort ! Don't know what to do without ur videos 💓 Lots of Love from Morocco 🌷🌷
@kathikr9360
@kathikr9360 3 ай бұрын
thanks for the amazing work brother
@martinemmerson2809
@martinemmerson2809 7 ай бұрын
Hi Bro, love this course on React 👍👍. Hope you can keep going into more advanced levels. 👍👍
@durgfestivalvibes
@durgfestivalvibes Ай бұрын
great video bro!!
@MusaMuhammedOlayinka
@MusaMuhammedOlayinka 5 ай бұрын
Thank you 😊
@LazizbekTurayev-bs8by
@LazizbekTurayev-bs8by 3 ай бұрын
thank you bro code you have helped alot to me
@marybenish9716
@marybenish9716 7 ай бұрын
Amazing
@minkhant4167
@minkhant4167 4 ай бұрын
thank you you are the best
@bostongreen1629
@bostongreen1629 Ай бұрын
Exceptional in the way you teach. Any chance to have the codes of the examples provided?
@KBHASKAR-
@KBHASKAR- 2 ай бұрын
Thanks
@FrostyBlue1712
@FrostyBlue1712 7 ай бұрын
Hey Bro, Noice vid
@Vincent_12770
@Vincent_12770 7 ай бұрын
After reacjs series could you please introduce nodejs or even golang series.... mostly for microservices
@zahersankari7342
@zahersankari7342 3 күн бұрын
you're a legend!
@codegenesis2130
@codegenesis2130 7 ай бұрын
Hi bro thank you so much for this. Can you please make a detailed react course instead of individual video about topics? Please make a video on next js also.
@Build33_Studio
@Build33_Studio 7 ай бұрын
Bro code pls reply to me i love your work❤❤❤🎉🎉🎉
@KingOfMadnesss
@KingOfMadnesss 7 ай бұрын
You should do a course on SFML (A C++ library)
@Niyaz_karma
@Niyaz_karma 7 ай бұрын
Where would you learn to code if you started over❤❤
@NoTimeWaste1
@NoTimeWaste1 Ай бұрын
1:51 This is one of the reason why I came here
@andromilk2634
@andromilk2634 5 ай бұрын
By the way, wouldn't using document.title = ... directly in the component be equivalent to useEffect(() =­> {document.title = ...}) ? In both cases, they are executed after each rerender?
@BishanTamang-rk5ji
@BishanTamang-rk5ji 7 ай бұрын
Make java 2024 plz....Big fan love from Nepal
@user-oy2mi4oz7t
@user-oy2mi4oz7t 29 күн бұрын
does this happen only in react js part of code ? i mean the millions of added listeners .. or it happens in normal js file too ?
@andromilk2634
@andromilk2634 5 ай бұрын
The only thing which I'm not sure of following is when does exactly a component unmount? Is this something which you manually have to do? Since you were able to change the title of your window by listening to the event, then I assume it never unmounted? (In other words, unmounting is done manually by you?) thanks
@rishabhkedia9304
@rishabhkedia9304 6 ай бұрын
Please make Reactjs projects as well
@suwanthadarshana8495
@suwanthadarshana8495 7 ай бұрын
Can you do spring boot series
@MagnusAnand
@MagnusAnand 6 ай бұрын
Have you tried htmx ??
@hawkar7kurdish440
@hawkar7kurdish440 Ай бұрын
what is Side Effect? please someone explain briefly
@mk-vg1mx
@mk-vg1mx 2 күн бұрын
@ruslangilyazov7733
@ruslangilyazov7733 5 ай бұрын
I appreciate you so much
@MO-vr1mw
@MO-vr1mw 7 ай бұрын
Can you do Laravel please
@rifatmunna
@rifatmunna 6 ай бұрын
can you make redux video?
@AIZEN155
@AIZEN155 7 ай бұрын
Fu*k logic mathematique , code bro is the best
@warlordff2395
@warlordff2395 7 ай бұрын
69th like🤪
@Albert_Hall
@Albert_Hall 3 ай бұрын
Very interesting and easy absorbable narration 🎉 Express: (i) => { Sincere gratitude }
Build a DIGITAL CLOCK using React in 15 minutes! 🕒
16:00
Bro Code
Рет қаралды 15 М.
React useRef() hook introduction 🗳️
11:18
Bro Code
Рет қаралды 15 М.
Slow motion boy #shorts by Tsuriki Show
00:14
Tsuriki Show
Рет қаралды 10 МЛН
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 17 МЛН
小宇宙竟然尿裤子!#小丑#家庭#搞笑
00:26
家庭搞笑日记
Рет қаралды 17 МЛН
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
#2: React Hooks | Реакт Хук useEffect за 10 минут | React Hook useEffect
10:55
Типичный Веб Разработчик
Рет қаралды 2,2 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 467 М.
JavaScript Pro Tips - Code This, NOT That
12:37
Fireship
Рет қаралды 2,5 МЛН
Mastering React's useEffect
25:20
Jack Herrington
Рет қаралды 173 М.
React useContext() hook introduction 🧗‍♂️
11:37
Bro Code
Рет қаралды 23 М.
All useEffect Mistakes Every Junior React Developer Makes
22:23
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 531 М.
Slow motion boy #shorts by Tsuriki Show
00:14
Tsuriki Show
Рет қаралды 10 МЛН