Use React to Scroll to Specific Section on Your Website

Поделиться
HTML-код
  • Опубликовано: 22 окт 2024

Комментарии • 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!

  • @asselyembergenovasdu6970
    @asselyembergenovasdu6970 Год назад +1

    Really cool👍👍👍👍

  • @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

  • @avcodeversee
    @avcodeversee 10 месяцев назад +1

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

    • @programwithabu
      @programwithabu  10 месяцев назад +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
      ruclips.net/video/_G5RxzxJz4A/видео.htmlsi=KCDBupMYFgbvxEwO

  • @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 :)

  • @rukiayusuf3502
    @rukiayusuf3502 2 года назад +1

    Wonderful tutorial Maashallah

  • @Joel-nz1gd
    @Joel-nz1gd 11 месяцев назад +1

    Thank you for the step by step explanation

    • @programwithabu
      @programwithabu  10 месяцев назад

      The video below might also help, where I show how to forward ref from one component to another
      ruclips.net/video/_G5RxzxJz4A/видео.htmlsi=KCDBupMYFgbvxEwO

  • @mdrezaulkarim4707
    @mdrezaulkarim4707 Год назад +1

    Very usefull video

  • @chiamakaorakwe8776
    @chiamakaorakwe8776 Год назад +1

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

    • @programwithabu
      @programwithabu  Год назад

      Glad I could help!

    • @programwithabu
      @programwithabu  Год назад

      ruclips.net/video/_G5RxzxJz4A/видео.html
      I also explain how to forward ref from on component to another using the link above

  • @faainamacaldera5125
    @faainamacaldera5125 2 года назад +2

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

  • @timmulwanyi5980
    @timmulwanyi5980 2 года назад +1

    Great work MUST OB

  • @faugofficial4891
    @faugofficial4891 10 месяцев назад +1

    Thanks man
    you explained it so easily

  • @user121304
    @user121304 2 года назад +1

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

  • @molomekeys3938
    @molomekeys3938 Год назад +1

    thank you very much

  • @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  Год назад

      Hi,
      Below is a video I made on how to accomplish this. I hope it helps
      ruclips.net/video/_G5RxzxJz4A/видео.html

  • @thomasalmeida9823
    @thomasalmeida9823 Год назад +1

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

    • @programwithabu
      @programwithabu  Год назад

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

  • @KishanKumar-cz9cy
    @KishanKumar-cz9cy Год назад +1

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

  • @momokee2394
    @momokee2394 Год назад +1

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

    • @programwithabu
      @programwithabu  Год назад

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

    • @momokee2394
      @momokee2394 Год назад +1

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

    • @programwithabu
      @programwithabu  Год назад +1

      @@momokee2394 I promised a video to solve this, and here you go.
      I hope it helps
      ruclips.net/video/_G5RxzxJz4A/видео.html

  • @maryamhabibpoor2356
    @maryamhabibpoor2356 Год назад +1

    that was very helpful for me. tank u

  • @ahmedsarhan3088
    @ahmedsarhan3088 Год назад +1

    woooow, amazing tutorial

  • @ife9556
    @ife9556 2 года назад +1

    Very clear explanation, thank you

  • @Rando327
    @Rando327 6 месяцев назад

    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 :(.

  • @bedsidetable
    @bedsidetable 2 года назад +1

    Very helpful video Abu! Thank you so much

    • @programwithabu
      @programwithabu  Год назад

      Glad I could help.
      this might also be helpful
      ruclips.net/video/_G5RxzxJz4A/видео.html

  • @ankitchauhan8682
    @ankitchauhan8682 2 года назад +2

    to the point, thanks

  • @gunnn269
    @gunnn269 Год назад

    Thanks bro. For these easy and clear explanations

  • @999slawter
    @999slawter Год назад +1

    Thank you very much! :)

  • @infomania_by_ayush7901
    @infomania_by_ayush7901 9 месяцев назад +1

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

    • @programwithabu
      @programwithabu  9 месяцев назад

      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

  • @NaradaUtoroDewo
    @NaradaUtoroDewo Год назад

    Thank you brother!

  • @PhoneyPatjordan
    @PhoneyPatjordan Год назад +1

    Thank you! This was very helpful!

  • @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
      ruclips.net/video/_G5RxzxJz4A/видео.html

  • @Najettechou
    @Najettechou Год назад

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

  • @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  10 месяцев назад

      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
      ruclips.net/video/_G5RxzxJz4A/видео.htmlsi=KCDBupMYFgbvxEwO

  • @mansichugh8129
    @mansichugh8129 6 месяцев назад

    what is the use of usereef?

  • @znkdev
    @znkdev Год назад +1

    Thanks, helped a lot!

  • @user-hr3eb7wt2c
    @user-hr3eb7wt2c Год назад +1

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

    • @programwithabu
      @programwithabu  Год назад

      Hi, I made a new video to solve this issue
      ruclips.net/video/_G5RxzxJz4A/видео.html

  • @aymanhaque
    @aymanhaque 9 месяцев назад

    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  9 месяцев назад

      Hi, I created another video to solve this issue, you can find it on the link below
      ruclips.net/video/_G5RxzxJz4A/видео.htmlsi=l75gYCqlR9_103TV
      How this helps out

  • @mariafernandaabreufonseca9640
    @mariafernandaabreufonseca9640 2 года назад +1

    That was helpful. Thank you

    • @programwithabu
      @programwithabu  Год назад

      Glad I could help
      This might also be helpful
      ruclips.net/video/_G5RxzxJz4A/видео.html

  • @zaheeriqbal8245
    @zaheeriqbal8245 Год назад +1

    can i use (useRef) on routers
    help?

    • @programwithabu
      @programwithabu  Год назад

      Good question Zaheer
      I made a video just for this
      ruclips.net/video/_G5RxzxJz4A/видео.html

  • @princewillduru7313
    @princewillduru7313 2 года назад +1

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

    • @programwithabu
      @programwithabu  Год назад

      Hi, sorry for this late reply
      I made a video to help with this, follow the link below
      ruclips.net/video/_G5RxzxJz4A/видео.html

  • @DnsMenjivar
    @DnsMenjivar Год назад

    10/10

  • @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  Год назад

      Hi, I believe this video below that I made will help solve this
      ruclips.net/video/_G5RxzxJz4A/видео.html

  • @mgpyaegyi6591
    @mgpyaegyi6591 2 года назад +1

    Love ❤ it guy keep moving

  • @aviroxi
    @aviroxi 2 года назад +1

    Thank you!!

  • @VanagilaRodrigues
    @VanagilaRodrigues 2 года назад +1

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

    • @programwithabu
      @programwithabu  Год назад +1

      Here's a link to my new video on how you can forward a ref
      ruclips.net/video/_G5RxzxJz4A/видео.html

  • @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

      @@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  Год назад

      @@Anastasia_Zhuravleva Hi, I made a video just for this, i hope it can help
      ruclips.net/video/_G5RxzxJz4A/видео.html

    • @programwithabu
      @programwithabu  Год назад

      @@muzamilrashid7265 Here's a link to a video where you can forward a ref
      ruclips.net/video/_G5RxzxJz4A/видео.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 Год назад +1

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

    • @programwithabu
      @programwithabu  Год назад +1

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

    • @programwithabu
      @programwithabu  Год назад +1

      @@subaruLover475 I promised a video on this topic and here you go, I hope it will help
      ruclips.net/video/_G5RxzxJz4A/видео.html

    • @programwithabu
      @programwithabu  Год назад

      Hi, I made a new video on this topic, I hope it can help
      ruclips.net/video/_G5RxzxJz4A/видео.html

  • @nicetomeetugaming7024
    @nicetomeetugaming7024 2 года назад +1

    Best video

  • @eduardoleitzke5803
    @eduardoleitzke5803 2 года назад +1

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

    • @programwithabu
      @programwithabu  Год назад

      Thanks Eduardo for your support all the way from Brazil

  • @josephsutcliffe9141
    @josephsutcliffe9141 2 года назад +1

    Works perfect, thanks mate 😁

    • @programwithabu
      @programwithabu  Год назад

      I'm glad I could help
      Here another video if you want to forward a ref from one component to another
      ruclips.net/video/_G5RxzxJz4A/видео.html

  • @zakariyyaism
    @zakariyyaism 2 года назад

    Mumtaaz Maa Shaa Allah

  • @zeke2269
    @zeke2269 Год назад

    How to solve that white gap im a beginner

    • @programwithabu
      @programwithabu  9 месяцев назад

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

  • @healingwithlove8614
    @healingwithlove8614 Год назад

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

  • @zeke2269
    @zeke2269 Год назад

    Second one is not that easy bruh💀