React useRef() hook introduction 🗳️

Поділитися
Вставка
  • Опубліковано 26 чер 2024
  • #reactjs #tutorial #course
    00:00:00 introduction
    00:01:01 setup
    00:03:02 useRef()
    00:05:11 html ref attribute
    00:08:06 multiple useRef()
    00:10:10 useState() vs useRef()
    00:10:28 conclusion
    // useState() = Re-renders the component when the state value changes
    // useRef() = Does not cause re-renders when its value changes.
    // 1. Accessing/Interacting with DOM elements
    // 2. Handling Focus, Animations, and Transitions
    // 3. Managing Timers and Intervals

КОМЕНТАРІ • 34

  • @BroCodez
    @BroCodez  5 місяців тому +8

    // useState() = Re-renders the component when the state value changes
    // useRef() = "use Reference" Does not cause re-renders when its value changes.
    // 1. Accessing/Interacting with DOM elements
    // 2. Handling Focus, Animations, and Transitions
    // 3. Managing Timers and Intervals
    import React, {useState, useEffect, useRef} from 'react';
    function MyComponent(){
    const inputRef1 = useRef(null);
    const inputRef2 = useRef(null);
    const inputRef3 = useRef(null);
    useEffect(() => {
    console.log("COMPONENT RENDERED");
    });
    function handleClick1(){
    inputRef1.current.focus();
    inputRef1.current.style.backgroundColor = "yellow";
    inputRef2.current.style.backgroundColor = "";
    inputRef3.current.style.backgroundColor = "";
    }
    function handleClick2(){
    inputRef2.current.focus();
    inputRef1.current.style.backgroundColor = "";
    inputRef2.current.style.backgroundColor = "yellow";
    inputRef3.current.style.backgroundColor = "";
    }
    function handleClick3(){
    inputRef3.current.focus();
    inputRef1.current.style.backgroundColor = "";
    inputRef2.current.style.backgroundColor = "";
    inputRef3.current.style.backgroundColor = "yellow";
    }
    return (


    Click me 1!



    Click me 2!



    Click me 3!



    );
    }
    export default MyComponent;

    • @lonelydevilcreations
      @lonelydevilcreations 5 місяців тому

      Plz make redux and context API videos

    • @iiTzBlaster
      @iiTzBlaster 4 місяці тому

      Hi BroCode! I'm reaching out because I'd like to contact you further. Could you share your email or Discord or something similar? I have some questions, ideas, and feedback I'd like to discuss. Looking forward to hearing from you!

    • @-_SleepAndEat_-
      @-_SleepAndEat_- 2 місяці тому

      Bro can you do Kali Linux ?

  • @JohnWickXD
    @JohnWickXD 3 місяці тому +3

    That's hands on the best explanation of useRef( ). Thanks again Bro

  • @valerylouis6747
    @valerylouis6747 5 місяців тому +3

    always happy with tutorials from Bro Code. much respect!

  • @kathikr9360
    @kathikr9360 2 місяці тому

    i have seen multiple classes and yours is clear and .Thank You

  • @muhammadumarsotvoldiev8768
    @muhammadumarsotvoldiev8768 Місяць тому +1

    Thank you very much From Uzbekistan Fergana 👍

  • @zuhabaw9976
    @zuhabaw9976 3 місяці тому +1

    just 178 likes???? are you kidding me?? This is the best tutorial video on useRef hook🥺
    No doubt all the videos from this channel are great but this one is just too clear and simple!
    feeling bad for the people who didn't/ couldn't find this video

  • @domkar4186
    @domkar4186 4 місяці тому +1

    Really very good content which we needed... useful in our work..thanks buddy....❤

  • @user-fb9yy3qb1o
    @user-fb9yy3qb1o 3 місяці тому +1

    Love it

  • @Hari-ce4wx
    @Hari-ce4wx 2 місяці тому

    Need More videos on react hooks as your videos are best.

  • @chommc375
    @chommc375 5 місяців тому +1

    love it
    from vn

  • @kathikr9360
    @kathikr9360 3 місяці тому +1

    thank you

  • @elitegaming8565
    @elitegaming8565 5 місяців тому +1

    Hi Again
    Love from India

  • @BishanTamang-rk5ji
    @BishanTamang-rk5ji 5 місяців тому +4

    Make 2024 java course love from Nepal 💓❤️

    • @user-vq1uq9ul6o
      @user-vq1uq9ul6o 5 місяців тому

      Yes plz make it❤

    • @quvomiddinkamalov3292
      @quvomiddinkamalov3292 2 місяці тому

      There is a Full Java course on his channel

    • @RychAhlberg
      @RychAhlberg Місяць тому

      They don’t teach you the word “please” when you learn English in Nepal? Don’t be rude.

  • @rishabhkedia9304
    @rishabhkedia9304 5 місяців тому +1

    Please make Reactjs projects as well

  • @ujjwalaggrawal5486
    @ujjwalaggrawal5486 5 місяців тому

    Bro,plz make a complete vid on React Js n Node Js,sort of full stack application series.
    Plzzzz🙏🙏🙏

  • @BLAZIN77KONG
    @BLAZIN77KONG 5 місяців тому +1

    Hello Bro, I love your tutorials but can you make a updated Java Tutorial? Love from India

  • @slhliwwa5403
    @slhliwwa5403 16 днів тому +1

    what does it mean the component re-render and what's the purpose of it ???

  • @Movie-xz3hw
    @Movie-xz3hw 5 місяців тому +1

    Why your videos doesn't show in my Subscription Section???

  • @lucasmikael9199
    @lucasmikael9199 5 місяців тому

    i want to use code which there is an text that can be renamed that is on the left down corner of the screen and there is a bigger one in the center of the screen , when the user renames the text to the video urlit will start to make the user choose an video file from the device and when uploaded in the video it will globally display the video there will be a mechanic for the place of the videos uploading , while a video is currently playing being first to be displayed when another user uploads a video the video will be in 1st place before being displayed and if the currently playing video ends the next one uploaded by the other user will be displayed

    • @lucasmikael9199
      @lucasmikael9199 5 місяців тому

      i need you to fix this code also


      UA-cam Video Player

      body {
      margin: 0;
      overflow: hidden;
      }
      #videoUrlInput {
      position: fixed;
      bottom: 40px;
      left: 40px;
      width: 300px;
      height: 30px;
      padding: 5px;
      font-size: 16px;
      }
      #videoContainer {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 80%;
      height: 80%;
      background-color: black;
      overflow: hidden;
      }
      video {
      width: 100%;
      height: 100%;
      }






      let isPlaying = false;
      function setVideoSource() {
      const videoUrlInput = document.getElementById('videoUrlInput');
      const videoPlayer = document.getElementById('videoPlayer');
      // Set the video source directly
      videoPlayer.src = videoUrlInput.value;
      // Play the video if not already playing
      if (!isPlaying) {
      videoPlayer.play();
      isPlaying = true;
      }
      }

  • @nguyenanh-vt4jv
    @nguyenanh-vt4jv 3 місяці тому +1

    at 1:22 can any want say me that what did he use to tab both the open tag and close tag of button

  • @Vincent_12770
    @Vincent_12770 5 місяців тому +1

    chief pleace make golang course or nodejs...

  • @KingOfMadnesss
    @KingOfMadnesss 5 місяців тому

    Day 2 of asking for an SFML full course (After the react course)

  • @workdaboi-ys5ob
    @workdaboi-ys5ob 5 місяців тому +1

    Dear Bro, much support on your videos. I'm learning web development from your channel, if you would do REACT COMPLETE TUTORIAL that would be really helpful. Thanks

  • @raitaskeen
    @raitaskeen 5 місяців тому

    Bro can you provide a RUST course????

  • @l213dhanesh3
    @l213dhanesh3 5 місяців тому

    Code bro... How are u man? Angular start padara

  • @Beanbag59
    @Beanbag59 4 місяці тому

    Do u tutor