Use React to Scroll to Specific Section on Your Website

  Рет қаралды 50,458

Program With Abu

Program With Abu

Күн бұрын

In this video, I show you how to use react to scroll to specific sections of your website. When you build a website with a single page, a user can navigate to specific section using clicks. We use the full power of JavaScript in this tutorial.
----------
Link to Github repository
👉 github.com/iAthman83/use-reac...
----------
Introduction to React 👉 • Introduction to Modern...
Routing with React 👉 • React Router - Introdu...
----------
Follow on Twitter 👉 / iathman83
Connect on LinkedIn 👉 / abubakar-athman-680015140
----------
Subscribe to my channel 👉 / @programwithabu
______
☕️Buy me coffee 👉 www.buymeacoffee.com/iathman83
----------
Chapters
00:00 Introduction
01:12 Setup vscode
01:30 Create navigation menu
04:21 Create sections
06:00 Adding Scroll effects
10:18 Implement back to top button
19:04 Wrap up
#reactjs #scroll #node #javascript #DOM

Пікірлер: 103
@craigjohnson8279
@craigjohnson8279 2 жыл бұрын
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 жыл бұрын
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 Жыл бұрын
Really cool👍👍👍👍
@Najettechou
@Najettechou Жыл бұрын
Thank you so much! This was really really helpful and very easy to follow.
@faainamacaldera5125
@faainamacaldera5125 2 жыл бұрын
thank you sir, you're explanation is so clear and i can understand it easily
@rukiayusuf3502
@rukiayusuf3502 2 жыл бұрын
Wonderful tutorial Maashallah
@user121304
@user121304 Жыл бұрын
I need this in my project currently. Will try it tomorrow. Thanks ! Can more react and typescript tutorials plz 😊
@isaacotim1955
@isaacotim1955 2 жыл бұрын
dude your videos are really awesome.....u have made REACT easy for me to master
@programwithabu
@programwithabu 2 жыл бұрын
Thank you for your kind words. I hope with this and my other tutorials can help you get started with your projects
@gunnn269
@gunnn269 Жыл бұрын
Thanks bro. For these easy and clear explanations
@aaaliii4u
@aaaliii4u Жыл бұрын
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 :)
@mdrezaulkarim4707
@mdrezaulkarim4707 Жыл бұрын
Very usefull video
@thomasalmeida9823
@thomasalmeida9823 Жыл бұрын
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
@faugofficial4891
@faugofficial4891 7 ай бұрын
Thanks man you explained it so easily
@KishanKumar-cz9cy
@KishanKumar-cz9cy Жыл бұрын
thanks man for such kind of videos, it is really helpful for me...
@znkdev
@znkdev Жыл бұрын
Thanks, helped a lot!
@ankitchauhan8682
@ankitchauhan8682 Жыл бұрын
to the point, thanks
@aviroxi
@aviroxi 2 жыл бұрын
Thank you!!
@theanushka_v18
@theanushka_v18 7 ай бұрын
Thank you so much Abu for explaining this, this will help me to apply in my portfolio website.
@programwithabu
@programwithabu 7 ай бұрын
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 kzbin.info/www/bejne/lXiYg6uwra-taqMsi=KCDBupMYFgbvxEwO
@bedsidetable
@bedsidetable Жыл бұрын
Very helpful video Abu! Thank you so much
@programwithabu
@programwithabu Жыл бұрын
Glad I could help. this might also be helpful kzbin.info/www/bejne/lXiYg6uwra-taqM
@999slawter
@999slawter Жыл бұрын
Thank you very much! :)
@user-cc1ef1xp3x
@user-cc1ef1xp3x 10 ай бұрын
Thank you brother!
@chiamakaorakwe8776
@chiamakaorakwe8776 Жыл бұрын
This was a very detailed tutorial with exceptional way of explaining hooks, thank you very much
@programwithabu
@programwithabu Жыл бұрын
Glad I could help!
@programwithabu
@programwithabu Жыл бұрын
kzbin.info/www/bejne/lXiYg6uwra-taqM I also explain how to forward ref from on component to another using the link above
@timmulwanyi5980
@timmulwanyi5980 2 жыл бұрын
Great work MUST OB
@programwithabu
@programwithabu 2 жыл бұрын
Thank you dude
@eduardoleitzke5803
@eduardoleitzke5803 2 жыл бұрын
very nice! great video, really usefull! thanks from Brasil
@programwithabu
@programwithabu Жыл бұрын
Thanks Eduardo for your support all the way from Brazil
@josephsutcliffe9141
@josephsutcliffe9141 Жыл бұрын
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 kzbin.info/www/bejne/lXiYg6uwra-taqM
@molomekeys3938
@molomekeys3938 Жыл бұрын
thank you very much
@ahmedsarhan3088
@ahmedsarhan3088 Жыл бұрын
woooow, amazing tutorial
@programwithabu
@programwithabu Жыл бұрын
Thank you Ahmed I'm glad i could help
@PhoneyPatjordan
@PhoneyPatjordan Жыл бұрын
Thank you! This was very helpful!
@programwithabu
@programwithabu Жыл бұрын
Glad I could help
@mgpyaegyi6591
@mgpyaegyi6591 2 жыл бұрын
Love ❤ it guy keep moving
@programwithabu
@programwithabu 2 жыл бұрын
Thank you 😊
@mariafernandaabreufonseca9640
@mariafernandaabreufonseca9640 Жыл бұрын
That was helpful. Thank you
@programwithabu
@programwithabu Жыл бұрын
Glad I could help This might also be helpful kzbin.info/www/bejne/lXiYg6uwra-taqM
@ife9556
@ife9556 Жыл бұрын
Very clear explanation, thank you
@programwithabu
@programwithabu Жыл бұрын
I’m glad I could help!
@Joel-nz1gd
@Joel-nz1gd 8 ай бұрын
Thank you for the step by step explanation
@programwithabu
@programwithabu 7 ай бұрын
The video below might also help, where I show how to forward ref from one component to another kzbin.info/www/bejne/lXiYg6uwra-taqMsi=KCDBupMYFgbvxEwO
@maryamhabibpoor2356
@maryamhabibpoor2356 Жыл бұрын
that was very helpful for me. tank u
@programwithabu
@programwithabu Жыл бұрын
Awesome!!! I’m glad I could help!
@DnsMenjivar
@DnsMenjivar 10 ай бұрын
10/10
@revasseurborn2000
@revasseurborn2000 Жыл бұрын
Thank you so much I wasted almost three days on this !
@programwithabu
@programwithabu Жыл бұрын
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 kzbin.info/www/bejne/lXiYg6uwra-taqM
@Rando327
@Rando327 3 ай бұрын
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 :(.
@nicetomeetugaming7024
@nicetomeetugaming7024 2 жыл бұрын
Best video
@programwithabu
@programwithabu Жыл бұрын
Thank you so much, I'm glad I could help
@mansichugh8129
@mansichugh8129 4 ай бұрын
what is the use of usereef?
@najeesimmons6648
@najeesimmons6648 2 жыл бұрын
Thanks for this. How is this accomplished when the "sections" are in fat different components, as opposed to simply different divs?
@programwithabu
@programwithabu 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 kzbin.info/www/bejne/lXiYg6uwra-taqM
@zakariyyaism
@zakariyyaism 2 жыл бұрын
Mumtaaz Maa Shaa Allah
@aymanhaque
@aymanhaque 7 ай бұрын
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 7 ай бұрын
Hi, I created another video to solve this issue, you can find it on the link below kzbin.info/www/bejne/lXiYg6uwra-taqMsi=l75gYCqlR9_103TV How this helps out
@momokee2394
@momokee2394 Жыл бұрын
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 Жыл бұрын
@@programwithabu wohooo! looking forward to watching and learning more from you
@programwithabu
@programwithabu Жыл бұрын
@@momokee2394 I promised a video to solve this, and here you go. I hope it helps kzbin.info/www/bejne/lXiYg6uwra-taqM
@princewillduru7313
@princewillduru7313 2 жыл бұрын
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 kzbin.info/www/bejne/lXiYg6uwra-taqM
@ketankumar5689
@ketankumar5689 2 жыл бұрын
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 kzbin.info/www/bejne/lXiYg6uwra-taqM
@girijeshthodupunuri1300
@girijeshthodupunuri1300 Жыл бұрын
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 7 ай бұрын
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 kzbin.info/www/bejne/lXiYg6uwra-taqMsi=KCDBupMYFgbvxEwO
@infomania_by_ayush7901
@infomania_by_ayush7901 6 ай бұрын
Hey But what if I am trying to interrupt the scroll when user is scrolling up? How can I do that?
@programwithabu
@programwithabu 6 ай бұрын
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
@user-hr3eb7wt2c
@user-hr3eb7wt2c Жыл бұрын
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 kzbin.info/www/bejne/lXiYg6uwra-taqM
@zaheeriqbal8245
@zaheeriqbal8245 Жыл бұрын
can i use (useRef) on routers help?
@programwithabu
@programwithabu Жыл бұрын
Good question Zaheer I made a video just for this kzbin.info/www/bejne/lXiYg6uwra-taqM
@healingwithlove8614
@healingwithlove8614 Жыл бұрын
I never done this like it i give the component a id and scroll to that id
@programwithabu
@programwithabu Жыл бұрын
Interesting way of doing it too
@zeke2269
@zeke2269 Жыл бұрын
How to solve that white gap im a beginner
@programwithabu
@programwithabu 7 ай бұрын
Sorry for responding to your comment late, Which white gap? But I hope you figured it out by now (:
@VanagilaRodrigues
@VanagilaRodrigues Жыл бұрын
This solution does not work if you are componentizing. any clue?
@programwithabu
@programwithabu Жыл бұрын
Here's a link to my new video on how you can forward a ref kzbin.info/www/bejne/lXiYg6uwra-taqM
@mahdibackar7015
@mahdibackar7015 2 жыл бұрын
what if the navbar is a defined in a separate component
@muzamilrashid7265
@muzamilrashid7265 2 жыл бұрын
Same Question
@programwithabu
@programwithabu 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 Жыл бұрын
@@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 kzbin.info/www/bejne/lXiYg6uwra-taqM
@programwithabu
@programwithabu Жыл бұрын
@@muzamilrashid7265 Here's a link to a video where you can forward a ref kzbin.info/www/bejne/lXiYg6uwra-taqM
@poojarathour6035
@poojarathour6035 2 жыл бұрын
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 Жыл бұрын
@@programwithabu can you do a video on this topic? would help a lot
@programwithabu
@programwithabu Жыл бұрын
I have a video coming out this week on this topic, I’ll share it here!
@programwithabu
@programwithabu Жыл бұрын
@@subaruLover475 I promised a video on this topic and here you go, I hope it will help kzbin.info/www/bejne/lXiYg6uwra-taqM
@programwithabu
@programwithabu Жыл бұрын
Hi, I made a new video on this topic, I hope it can help kzbin.info/www/bejne/lXiYg6uwra-taqM
@zeke2269
@zeke2269 Жыл бұрын
Second one is not that easy bruh💀
Smooth Scroll to an Element in React
8:38
Colby Fayock
Рет қаралды 27 М.
React Responsive Navigation Menu [2022]
35:27
Program With Abu
Рет қаралды 876
Can A Seed Grow In Your Nose? 🤔
00:33
Zack D. Films
Рет қаралды 30 МЛН
Useful gadget for styling hair 🤩💖 #gadgets #hairstyle
00:20
FLIP FLOP Hacks
Рет қаралды 11 МЛН
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 17 МЛН
Subtle, yet Beautiful Scroll Animations
5:04
Beyond Fireship
Рет қаралды 1,6 МЛН
React Firebase Tutorial: Securing Protected Routes in Your App
1:07:01
Program With Abu
Рет қаралды 2,8 М.
Stop, Intel’s Already Dead! - AMD Ryzen 9600X & 9700X Review
13:47
Linus Tech Tips
Рет қаралды 945 М.
JPEG is Dying - And that's a bad thing
8:09
2kliksphilip
Рет қаралды 177 М.
How I Coded An Entire Website Using ChatGPT
18:22
Nick White
Рет қаралды 1,9 МЛН
Incredible scroll-based animations with CSS-only
32:23
Kevin Powell
Рет қаралды 403 М.
The Story of Next.js
12:13
uidotdev
Рет қаралды 560 М.
New AI ROBOT with 3 Brains SHOCKED Experts!
9:16
AI Revolution
Рет қаралды 2,9 М.
Can A Seed Grow In Your Nose? 🤔
00:33
Zack D. Films
Рет қаралды 30 МЛН