How To Smooth Scroll in React - Smooth Scrolling Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 พ.ย. 2024

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

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

    I''ve been dealing with this for 3 days and you made it so easy! thank u so much!

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

      You bet! I’m glad you got it sorted out Deborah!

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

    Thanks so much! redoing my previous portfolio that was Angular into React and ran into this issue.

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

    Thanks alot bro, Great video.
    Very short, simple and clear way of explaining.

  • @augustineedeh3565
    @augustineedeh3565 7 หลายเดือนก่อน

    Found this super-duper helpful. Thanks man!

  • @gamingcave4386
    @gamingcave4386 6 หลายเดือนก่อน

    Thank you for the video. I have been trying to get this work since last three days.

  • @anarosol6133
    @anarosol6133 6 หลายเดือนก่อน

    Just what I needed. Thanks!!!!!!

  • @DIEGORAMIREZ-b4e
    @DIEGORAMIREZ-b4e 5 หลายเดือนก่อน

    Thank you, you helped me a lot...
    Greetings from Mexico.. :)

  • @anantheswar9048
    @anantheswar9048 4 หลายเดือนก่อน

    clean and clear!

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

    Thx man, i watch your vids from a while and i just want to say they helped so thanks

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

    Short and easy to follow thanks

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

    mascha Allah, always explained very clear tip top

  • @Coderruhit
    @Coderruhit 4 หลายเดือนก่อน

    just wow awesome explain thanks 😍

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

    Honestly the best video on this topic!

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

    Thank You soo much brooo.....I spent hours on trying various way

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

    Thank you for this! saved my life!!

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

    Thank you, you are my life saver, Ive been struggling with this for 2 days 🤩

  • @DuminoreDev
    @DuminoreDev 5 หลายเดือนก่อน

    Awesome, thank you!

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

    Thank you for the video! Very much appreciated!

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

    thats exactly what i was looking for! thanks man

  • @MehndiBySoukayna
    @MehndiBySoukayna 15 วันที่ผ่านมา

    yesssss man thank you!!!!!

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

    Another way of achieving this in modern browsers is to set the css scroll-behavior of the html/body to smooth.

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

      Thank you for the feedback - I will definitely try this. :)

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

      BOOM! Worked, without changing anything in my code. Thank you!

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

      @@kalahari8295 u need set important!, because the browser have a default scroll-behavior

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

      It works but it will keep reloading your page which u dont need in your react app since it is a Single Page App

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

    U made it simple man ur subscribers are well deserved

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

    Thank you for the video, helped me a lot! Got one more subscriber

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

    I've been struggling finding how to scroll to another # without changing the URL. Thank you so much for sharing this!

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

    Thank you, this helped tremendously!

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

    Thank you very much for this great content. It work!

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

    HUGE thank you! Redoing my portfolio and was stuck on this issue. You demo'd clearly and concisely. Cheers!

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

    Thanks so much brother. Awesome tutorial!

  • @karankhaira8497
    @karankhaira8497 26 วันที่ผ่านมา

    Thanks man.

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

    Great video! :)

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

    You really saved my ass today

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

    Thank you so much for this! A great help!

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

    Wow... Really awesome

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

    Amazing!

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

    very helpful, thank you so much

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

    Thank you very much for this great content. Really helped !

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

    Thanks bro, you made it easy!

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

    thanks my brother

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

    amazing content!

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

    Thank you. very short and concise explanations I like it.

  • @ASHOKKUMAR-vx1uh
    @ASHOKKUMAR-vx1uh 2 ปีที่แล้ว

    Thanks man realy helpful

  • @mustangboy3533
    @mustangboy3533 8 หลายเดือนก่อน

    Thanks 😊❤

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

    Hi, this works only second time click after fresh page reload. on the initial click the offset will be messed up but on second click perfect

  • @fakhruddinshovon8385
    @fakhruddinshovon8385 11 หลายเดือนก่อน

    really that's nice

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

    so good thankyou!

  • @fatimaiqra2169
    @fatimaiqra2169 4 หลายเดือนก่อน

    thanks a lot!

  • @shubha.tshubha.t8997
    @shubha.tshubha.t8997 ปีที่แล้ว

    THUMBS UP

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

    really good one help full for me
    🌹🌹🌹🌹🌹

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

    Very good

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

    Thank u man

  • @truewisdom1123
    @truewisdom1123 7 หลายเดือนก่อน

    Thanks alot ❤

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

    Thanks for the video...Thanks a lot

  • @MegaMetallica4ever
    @MegaMetallica4ever 10 หลายเดือนก่อน

    Thank you so much for this video, but can you tell me how to make a path display in the url. I have no problem achieving all of this when I have a multipage app.

  • @Adam-vm6tc
    @Adam-vm6tc 2 ปีที่แล้ว

    Thank you I've been working on this for 3 days and also trying to get ugly hash out of the url with the link. I had no idea this package existed.

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

    Thank you so much sir

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

    thank you

  • @Nilesh-y3b
    @Nilesh-y3b ปีที่แล้ว

    Thanks i understand

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

    thanks. very good

  • @jeckjonny6448
    @jeckjonny6448 3 หลายเดือนก่อน

    Hello, thank you very much for the video. There is a question, how can I make this approach so that when the page is reloaded, the scroll will automatically go to the top and not be saved in the active section of the page?

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

    this helped a lot Tq

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

    Outstanding! How to scroll on page load without a click? useEffect maybe? thanks!

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

      I used ' const handleWindowsLoad = () => {
      scroll.scrollToTop();
      setActiveSection('home');
      };
      window.addEventListener('load', handleWindowsLoad);'
      Maybe this work for you too

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

    Thanks alot!

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

    I came, found the source code, I hit the like button, subscribe button... and byeeeeeee! Thanks!

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

    thanks sir😊😊😊😊😊😊😊😊😊😊

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

    Спасибо большое, Клинт 🙏

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

    I got my solution here ! Tq

  • @ДмитроКвітчатий
    @ДмитроКвітчатий ปีที่แล้ว

    thx

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

    Hi, I created react app using vite and i am using tailwindcss for styling. I followed your tutorial still its not working. I even tried with tailwind class for smooth scrolling. Can anyone please help

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

    ```Just use this one line of css```
    inside public/index.html
    html {
    scroll-behavior: smooth;
    }

  • @anantjain9679
    @anantjain9679 5 หลายเดือนก่อน

    can we change the route on scrolling like active nav items

  • @khalediman9740
    @khalediman9740 6 หลายเดือนก่อน

    Thank you for the helpful video you've made. However, I have an issue with hiding the Id from the URL, I mean when I navigate to a specific section inside the same page I don't want the section Id to appear after the localhost:3000, like for example localhost:3000/#About. I've tried to use the hashSpy from react-scroll library, however it didn't' work, so can someone help me with that?

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

    can you make a project with React and GraphQL? maybe a CRUD project with backend end React Typescript?

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

    THANK YOU LORD THANK YOU JESUS AND THANK YOU SIRRRR

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

      Thank you! Also you can use “scroll-behavior” in CSS :)

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

    Thanks, subscribed & liked, the one thing i want to know, how to use this react-scroll with react-router-dom v6, both have Link tag??, kindly give a solution

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

      I would advise using only one feature on a specific page. This would clear up that issue.

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

      You can import Link as LinkRouter for example it will just re-name it .

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

    I don't know why my scroll element is weird. it keeps scrolling to the bottom of the clicked element, instead of showing it from the top ;(. Please help...

  • @Rob-J-BJJ
    @Rob-J-BJJ ปีที่แล้ว

    whenever I hover over the button the mouse icon turns into the typing icon how do I fix this

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

    Thor himself has descended from Asgard to teach us code!
    Works great, thanks a lot. So if I got this right, it can't handle switching to another page & then scroll?

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

      HAHA so awesome- thanks dude! That's a great question - I bet we can swing that! I'll play around with it.

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

    ur such amazing

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

    hi, why not use the property css. scroll-behavior: smooth;? good practices?
    but this package doesn't change the url, thats perfect for single page app, like a portfolio maybe... thx

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

    Thank you for the great video.
    I have one question. I am creating header that jumps to desired contents with the link in header, but I have no idea how to make the header component responsive. I am using react-bootstrap and I have already made header with it. I would like to know how to make the header made in bootstrap with react-scroll.

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

    I Ve tried to use it with Next js but it seems like there is a conflict with the Link component from Next js…How can I implement it in Next Js please?

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

    Hello! Thanks for this, it's great! But I have a problem because, for example, if I am in the 'demo' section and I click on the 'home' section, the css style for the 'active' class is applied on top of 'demo', then 'testimonials', then ' about' and then 'home', but the idea is that the 'active' class applies only to the section I click on. Do you know what I'm doing wrong or what is the solution?

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

    Is this work also when i click on the link
    When i click on the link i go down to the section and the active change depending on it?

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

    Hey man! Really nice video,
    I just have one question. I need to do automatic scrolling if I get new message. I handle to get new div with special ID, that's all good. But how I can make for example function, and everytime I will run it, It will do automatic that ?
    I hope you understand what I mean and Thank you!

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

      I'm sorry, I don't think I am 100% following. Are you referring to an onClick event that could trigger a function to scroll to a specific part of the page?

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

    What if you want to use { Link } from react-router-dom as well? It gives errors with the two imports being the same

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

      I imagine you'll probably have to import one using the 'as' keyword to change the name of your import

  • @kunwarpreetsingh8314
    @kunwarpreetsingh8314 6 หลายเดือนก่อน

    why it's not working on my website

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

    What would I do if I have a contact page that is separate from the home page? I want to navigate to certain sections on the home page from the contact page.

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

      use react router dom library for ur code

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

    3:40

  • @Salmankhan_38827
    @Salmankhan_38827 3 หลายเดือนก่อน

    Hah just apply scroll-behaviour : smooth; in css and you are done.

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

    When you click on each nav bar to navigate to a specific section, the link renders localhost:3000/#about. It didn't change the name of that section localhost:3000/#demo. What changes should be made to fix that? Thanks for your efforts Man!!

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

    // go to section
    if (window.location.pathname === "/Projects") {
    console.log(
    document.querySelector("#Projects").getBoundingClientRect().top
    );
    }
    window.scrollTo({
    top: document.querySelector("#Projects").getBoundingClientRect().top,
    left: 0,
    behavior: "smooth",
    });
    }

  • @NeerajKumar-wk4qq
    @NeerajKumar-wk4qq ปีที่แล้ว

    Thank you so much sir

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

    thank you