Это видео недоступно.
Сожалеем об этом.

How To Smooth Scroll in React - Smooth Scrolling Tutorial

Поделиться
HTML-код
  • Опубликовано: 9 ноя 2021
  • In this video I show you how to implement smooth scrolling in React JS. I do this by using the "react-scroll" package. This is built on top of a previous React tutorial I put out. You can either implement this into your own project or if you want to clone my github repository then please feel free!
    Would love to hear any comments or questions from you guys!
    Thank you for watching.
    ZeroTo Mastery:
    - Master React JS Course - bit.ly/Learn-React-JS
    - Complete Web Developer in 2023 - bit.ly/Complete-Web-Developer...
    Coding Challenges!
    bit.ly/Code-Challenges
    Github repo for this project:
    github.com/fireclint/execute-...
    If you want to build this entire React app from the beginning then you may find the video here:
    • React Website Beginner...
    ☕ Buy me a Coffee ☕
    www.buymeacoffee.com/clintbriley
    Instagram 💪
    / fireclint
    🔥 My Coding Equipment 🔥
    Logitech MX Wireless Keyboard - amzn.to/3xKPFiN
    Logitech MX Master 2S Wireless Mouse - amzn.to/3O5WmRD
    SAMSUNG 49-Inch Gaming Monitor - amzn.to/3mvUy8M
    Shure MV7 USB Podcast Microphone - amzn.to/3O00nqG
    Mic Boom Arm - amzn.to/3NHn6YU
    Monitor Desk Light Bar - amzn.to/3xzKlyj

Комментарии • 127

  • @muhammadjonnazarov146
    @muhammadjonnazarov146 2 года назад +7

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

  • @deborahsanchez9607
    @deborahsanchez9607 2 года назад +12

    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!

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

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

  • @gamingcave4386
    @gamingcave4386 3 месяца назад

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

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

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

  • @augustineedeh3565
    @augustineedeh3565 3 месяца назад

    Found this super-duper helpful. Thanks man!

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

    U made it simple man ur subscribers are well deserved

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

    Thank you, this helped tremendously!

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

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

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

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

  • @anarosol6133
    @anarosol6133 2 месяца назад

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

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

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

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

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

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

    Honestly the best video on this topic!

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

    Thank you for this! saved my life!!

  • @anantheswar9048
    @anantheswar9048 25 дней назад

    clean and clear!

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

    Thank you for the video! Very much appreciated!

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

    Thank you so much for this! A great help!

  • @graysonharvey6933
    @graysonharvey6933 Год назад +2

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

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

    Wow... Really awesome

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

    Amazing!

  • @user-nr2og8ol4e
    @user-nr2og8ol4e Месяц назад

    just wow awesome explain thanks 😍

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

    thats exactly what i was looking for! thanks man

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

    very helpful, thank you so much

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

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

  • @DuminoreDev
    @DuminoreDev 2 месяца назад

    Awesome, thank you!

  • @ASHOKKUMAR-vx1uh
    @ASHOKKUMAR-vx1uh 2 года назад

    Thanks man realy helpful

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

    Thanks so much brother. Awesome tutorial!

  • @truewisdom1123
    @truewisdom1123 4 месяца назад

    Thanks alot ❤

  • @user-un7bf7gj3o
    @user-un7bf7gj3o Месяц назад

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

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

    Short and easy to follow thanks

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

    Thank u man

  • @mustangboy3533
    @mustangboy3533 5 месяцев назад

    Thanks 😊❤

  • @fatimaiqra2169
    @fatimaiqra2169 Месяц назад

    thanks a lot!

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

    Thanks bro, you made it easy!

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

    Great video! :)

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

    this helped a lot Tq

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

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

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

    so good thankyou!

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

    thanks. very good

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

    Thank you so much sir

  • @fakhruddinshovon8385
    @fakhruddinshovon8385 7 месяцев назад

    really that's nice

  • @user-zx2xt5bz3x
    @user-zx2xt5bz3x 10 месяцев назад

    Thanks i understand

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

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

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

    Thanks for the video...Thanks a lot

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

    thank you

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

    amazing content!

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

    Very good

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

    thanks my brother

  • @abdulsamman2229
    @abdulsamman2229 Год назад +2

    mascha Allah, always explained very clear tip top

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

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

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

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

    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.

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

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

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

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

    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.

  • @user-re7xn4rv6l
    @user-re7xn4rv6l 11 месяцев назад

    thx

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

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

  • @shubha.tshubha.t8997
    @shubha.tshubha.t8997 11 месяцев назад

    THUMBS UP

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

    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

  • @jeckjonny6448
    @jeckjonny6448 5 дней назад

    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?

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

    I got my solution here ! Tq

  • @frontendwithsalimi
    @frontendwithsalimi 11 месяцев назад

    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?

  • @khalediman9740
    @khalediman9740 3 месяца назад

    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?

  • @anantjain9679
    @anantjain9679 Месяц назад

    can we change the route on scrolling like active nav items

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

    ur such amazing

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

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

  • @Rob-J-BJJ
    @Rob-J-BJJ 9 месяцев назад

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

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

  • @Sahrawiyun
    @Sahrawiyun 2 года назад +10

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

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

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

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

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

    • @s1art7-vu5pl
      @s1art7-vu5pl Год назад

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

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

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

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

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

  • @farhana5499
    @farhana5499 5 месяцев назад

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

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

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

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

  • @s1art7-vu5pl
    @s1art7-vu5pl Год назад

    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

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

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

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

    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.

  • @kunwarpreetsingh8314
    @kunwarpreetsingh8314 2 месяца назад

    why it's not working on my website

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

    3:40

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

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

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

  • @Salmankhan_38827
    @Salmankhan_38827 8 дней назад

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

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

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

    Thanks alot!

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

    thank you