Use React to Scroll to Specific Section on Your Website

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ม.ค. 2025

ความคิดเห็น • 103

  • @craigjohnson8279
    @craigjohnson8279 2 ปีที่แล้ว +5

    I never had a need for useRef's before this video. Now I see how useful they are when scrolling to a section. Great video Abu! :)

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว +1

      Than you so much (:
      I’m glad you can now think about how to use in your next project!
      It’s an awesome hook used if there’s no need to re-render a component, like in this case!

  • @isaacotim1955
    @isaacotim1955 2 ปีที่แล้ว +7

    dude your videos are really awesome.....u have made REACT easy for me to master

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว +1

      Thank you for your kind words.
      I hope with this and my other tutorials can help you get started with your projects

  • @asselyembergenovasdu6970
    @asselyembergenovasdu6970 ปีที่แล้ว +1

    Really cool👍👍👍👍

  • @chiamakaorakwe8776
    @chiamakaorakwe8776 2 ปีที่แล้ว +1

    This was a very detailed tutorial with exceptional way of explaining hooks, thank you very much

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Glad I could help!

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html
      I also explain how to forward ref from on component to another using the link above

  • @KishanKumar-cz9cy
    @KishanKumar-cz9cy 2 ปีที่แล้ว +1

    thanks man for such kind of videos, it is really helpful for me...

  • @faainamacaldera5125
    @faainamacaldera5125 2 ปีที่แล้ว +2

    thank you sir, you're explanation is so clear and i can understand it easily

  • @avcodeversee
    @avcodeversee ปีที่แล้ว +1

    Thank you so much Abu for explaining this, this will help me to apply in my portfolio website.

    • @programwithabu
      @programwithabu  ปีที่แล้ว +1

      We’re most welcome, I’m glad I could help
      The video below might also help, where I show how to forward ref from one component to another
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.htmlsi=KCDBupMYFgbvxEwO

  • @faugofficial4891
    @faugofficial4891 ปีที่แล้ว +1

    Thanks man
    you explained it so easily

  • @Joel-nz1gd
    @Joel-nz1gd ปีที่แล้ว +1

    Thank you for the step by step explanation

    • @programwithabu
      @programwithabu  ปีที่แล้ว

      The video below might also help, where I show how to forward ref from one component to another
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.htmlsi=KCDBupMYFgbvxEwO

  • @ahmedsarhan3088
    @ahmedsarhan3088 2 ปีที่แล้ว +1

    woooow, amazing tutorial

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Thank you Ahmed
      I'm glad i could help

  • @thomasalmeida9823
    @thomasalmeida9823 2 ปีที่แล้ว +1

    I will implement it now in my project! Thank you, and by the way, you have great teaching skills.

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Thank you so much for your kind words
      And I’m so glad I could help

  • @bedsidetable
    @bedsidetable 2 ปีที่แล้ว +1

    Very helpful video Abu! Thank you so much

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Glad I could help.
      this might also be helpful
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @timmulwanyi5980
    @timmulwanyi5980 2 ปีที่แล้ว +1

    Great work MUST OB

  • @mdrezaulkarim4707
    @mdrezaulkarim4707 2 ปีที่แล้ว +1

    Very usefull video

  • @rukiayusuf3502
    @rukiayusuf3502 2 ปีที่แล้ว +1

    Wonderful tutorial Maashallah

  • @user121304
    @user121304 2 ปีที่แล้ว +1

    I need this in my project currently. Will try it tomorrow. Thanks ! Can more react and typescript tutorials plz 😊

  • @mgpyaegyi6591
    @mgpyaegyi6591 2 ปีที่แล้ว +1

    Love ❤ it guy keep moving

  • @gunnn269
    @gunnn269 ปีที่แล้ว

    Thanks bro. For these easy and clear explanations

  • @maryamhabibpoor2356
    @maryamhabibpoor2356 2 ปีที่แล้ว +1

    that was very helpful for me. tank u

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Awesome!!!
      I’m glad I could help!

  • @ife9556
    @ife9556 2 ปีที่แล้ว +1

    Very clear explanation, thank you

  • @PhoneyPatjordan
    @PhoneyPatjordan ปีที่แล้ว +1

    Thank you! This was very helpful!

  • @Najettechou
    @Najettechou ปีที่แล้ว

    Thank you so much! This was really really helpful and very easy to follow.

  • @josephsutcliffe9141
    @josephsutcliffe9141 2 ปีที่แล้ว +1

    Works perfect, thanks mate 😁

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      I'm glad I could help
      Here another video if you want to forward a ref from one component to another
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @aaaliii4u
    @aaaliii4u ปีที่แล้ว +3

    its a great a easy to follow tutorial, but you did not remove the event in the useEffect. you should remove that event so when the component is closed that event is also closed. Thank you for such a good lecture :)

  • @znkdev
    @znkdev 2 ปีที่แล้ว +1

    Thanks, helped a lot!

  • @eduardoleitzke5803
    @eduardoleitzke5803 2 ปีที่แล้ว +1

    very nice! great video, really usefull! thanks from Brasil

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Thanks Eduardo for your support all the way from Brazil

  • @mariafernandaabreufonseca9640
    @mariafernandaabreufonseca9640 2 ปีที่แล้ว +1

    That was helpful. Thank you

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Glad I could help
      This might also be helpful
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @ankitchauhan8682
    @ankitchauhan8682 2 ปีที่แล้ว +2

    to the point, thanks

  • @girijeshthodupunuri1300
    @girijeshthodupunuri1300 ปีที่แล้ว +1

    What do I do if the different sections are housed deep in custom components? How can i pass the ref from parent to deep nested child component?

    • @programwithabu
      @programwithabu  ปีที่แล้ว

      We’re most welcome, I’m glad I could help
      The video below might also help, where I show how to forward ref from one component to another
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.htmlsi=KCDBupMYFgbvxEwO

  • @999slawter
    @999slawter 2 ปีที่แล้ว +1

    Thank you very much! :)

  • @NaradaUtoroDewo
    @NaradaUtoroDewo ปีที่แล้ว

    Thank you brother!

  • @user-hr3eb7wt2c
    @user-hr3eb7wt2c 2 ปีที่แล้ว +1

    How about if all my navbar items each one in a single folder and a I import them in app.js ??

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Hi, I made a new video to solve this issue
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @aymanhaque
    @aymanhaque ปีที่แล้ว

    How would I implement this if I have multiple components in my react page? For example, my page has a navbar.js file which is exported to app.js(and this also imports all the sections from other files/components). How could I implement this in that case?

    • @programwithabu
      @programwithabu  ปีที่แล้ว

      Hi, I created another video to solve this issue, you can find it on the link below
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.htmlsi=l75gYCqlR9_103TV
      How this helps out

  • @najeesimmons6648
    @najeesimmons6648 2 ปีที่แล้ว +4

    Thanks for this. How is this accomplished when the "sections" are in fat different components, as opposed to simply different divs?

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว +2

      Hi Najee, sorry for late response...
      Basically you need to forward this ref using the forwardRef() hook to do this, great official article here from react. Le me know if this helps
      reactjs.org/docs/forwarding-refs.html

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Hi,
      Below is a video I made on how to accomplish this. I hope it helps
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @mansichugh8129
    @mansichugh8129 9 หลายเดือนก่อน

    what is the use of usereef?

  • @mahdibackar7015
    @mahdibackar7015 2 ปีที่แล้ว +3

    what if the navbar is a defined in a separate component

    • @muzamilrashid7265
      @muzamilrashid7265 2 ปีที่แล้ว +1

      Same Question

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว +2

      Hi Mahdi, sorry for late response...
      Basically you need to forward this ref using the forwardRef() hook to do this, great official article here from react. Le me know if this helps
      reactjs.org/docs/forwarding-refs.html

    • @Anastasia_Zhuravleva
      @Anastasia_Zhuravleva 2 ปีที่แล้ว +2

      @@programwithabu Hi ABu! Thank you so much for this video! i've been struggling for days to find the solution to scrolling within the same page and then I found your video.
      But I'm also using different components and even though I read the docs on forwardRef() I don't quite understand how the structure should be?
      I have a Parent component that has Header with nav links AND Sections that has these refs. Do i declare useRefs(null) in the parent component? as well as the function scrollToSection? or is it the other way around? If declaring useRefs and function in Header component, how do I pass refs from Sections in Parent component to Header?
      Please help I'll be very thankful

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      @@Anastasia_Zhuravleva Hi, I made a video just for this, i hope it can help
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      @@muzamilrashid7265 Here's a link to a video where you can forward a ref
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @blueb06
    @blueb06 ปีที่แล้ว +1

    Thank you so much I wasted almost three days on this !

    • @programwithabu
      @programwithabu  ปีที่แล้ว +1

      You’re very welcome!
      I’m glad I could help
      If you also wanna pass this ref between component here’s my video for that
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @ketankumar5689
    @ketankumar5689 2 ปีที่แล้ว +1

    How to navigate to some other page present in my project after clicking a link present in my homepage where I have implemented react-scroll ? Please advise.

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Hi, I believe this video below that I made will help solve this
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @ayush-6041
    @ayush-6041 ปีที่แล้ว +1

    Hey But what if I am trying to interrupt the scroll when user is scrolling up?
    How can I do that?

    • @programwithabu
      @programwithabu  ปีที่แล้ว

      Interrupting the scroll?
      The way this one is setup is that the scroll goes up to the top of the page.
      You can setup yours with the mouse listener event, if I understand your question correctly

  • @zaheeriqbal8245
    @zaheeriqbal8245 2 ปีที่แล้ว +1

    can i use (useRef) on routers
    help?

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Good question Zaheer
      I made a video just for this
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @momokee2394
    @momokee2394 2 ปีที่แล้ว +1

    thank you! what do you suggest if i want to divide those sections into separate components?

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      I’m sharing a video this week, on how to do this!
      Passing refs from one component to another

    • @momokee2394
      @momokee2394 2 ปีที่แล้ว +1

      @@programwithabu wohooo! looking forward to watching and learning more from you

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว +1

      @@momokee2394 I promised a video to solve this, and here you go.
      I hope it helps
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @poojarathour6035
    @poojarathour6035 2 ปีที่แล้ว +1

    hey ! I created different components, I create a header, and imported them into pages, this approach not working please help me out.

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Great question Pooja!
      Basically you need to forward this ref to another component using the forwardRef() hook.
      Great article on how to do this here
      reactjs.org/docs/forwarding-refs.html
      I hope that helps, let me know

    • @subaruLover475
      @subaruLover475 2 ปีที่แล้ว +1

      @@programwithabu can you do a video on this topic? would help a lot

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว +1

      I have a video coming out this week on this topic, I’ll share it here!

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว +1

      @@subaruLover475 I promised a video on this topic and here you go, I hope it will help
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Hi, I made a new video on this topic, I hope it can help
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @molomekeys3938
    @molomekeys3938 2 ปีที่แล้ว +1

    thank you very much

  • @DnsMenjivar
    @DnsMenjivar ปีที่แล้ว

    10/10

  • @nicetomeetugaming7024
    @nicetomeetugaming7024 2 ปีที่แล้ว +1

    Best video

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Thank you so much, I'm glad I could help

  • @zakariyyaism
    @zakariyyaism 2 ปีที่แล้ว

    Mumtaaz Maa Shaa Allah

  • @aviroxi
    @aviroxi 2 ปีที่แล้ว +1

    Thank you!!

  • @Rando327
    @Rando327 9 หลายเดือนก่อน

    thank you for this tutorial, wonderfully explained. But what if each section is a component on its own? For example the Nav is a component, the About section is another component. and all of them gathered in the App.js!
    I'm having problems understanding how can I do it when each section is a component on its own, HELP :(.

  • @VanagilaRodrigues
    @VanagilaRodrigues 2 ปีที่แล้ว +1

    This solution does not work if you are componentizing. any clue?

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว +1

      Here's a link to my new video on how you can forward a ref
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @princewillduru7313
    @princewillduru7313 2 ปีที่แล้ว +1

    Thank you for this. But I'm finding it hard to understand the forwardRef

    • @programwithabu
      @programwithabu  2 ปีที่แล้ว

      Hi, sorry for this late reply
      I made a video to help with this, follow the link below
      th-cam.com/video/_G5RxzxJz4A/w-d-xo.html

  • @healingwithlove8614
    @healingwithlove8614 ปีที่แล้ว

    I never done this like it i give the component a id and scroll to that id

  • @zeke2269
    @zeke2269 ปีที่แล้ว

    How to solve that white gap im a beginner

    • @programwithabu
      @programwithabu  ปีที่แล้ว

      Sorry for responding to your comment late,
      Which white gap?
      But I hope you figured it out by now (:

  • @zeke2269
    @zeke2269 ปีที่แล้ว

    Second one is not that easy bruh💀