How To Create A Navbar In React With Routing

Поделиться
HTML-код
  • Опубликовано: 6 июн 2024
  • FREE React Hooks Course: courses.webdevsimplified.com/...
    Navbars are one of the most common components you will create in React. Creating a good navbar also teaches core concepts about how React and routing work together which makes this the perfect beginner project. In this video I will show you how to implement a navbar with routing both from scratch and with React Router.
    📚 Materials/References:
    GitHub Code: github.com/WebDevSimplified/r...
    FREE React Hooks Course: courses.webdevsimplified.com/...
    🌎 Find Me Here:
    My Blog: blog.webdevsimplified.com
    My Courses: courses.webdevsimplified.com
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/WebDevSimplified
    CodePen: codepen.io/WebDevSimplified
    ⏱️ Timestamps:
    00:00 - Introduction
    00:48 - Navbar HTML
    02:24 - Navbar CSS
    05:55 - Routing without React router
    12:30 - Routing with React router
    #React #WDS #Navbar

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

  • @NiaNic425
    @NiaNic425 Год назад +13

    This is so great for portfolios! I was just considering moving my web portfolio from the old php mysql to react since I dont have much data to use for database anyway. Learning react, about routes and being able to update portfolio all at the same time with this vid thank you so much man!

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

    Thanks Kyle!! I have been stuck at react routing errors. My pages won't show on my home page but after watching your video. I got solution. Keep growing brother.

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

    Without even watching the video, I already know this was EXACTLY what I was looking for today from you...weird how life works out like that.

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

    Hey Kyle, thanks for making this. I've come across your channel over the last couple of weeks and finding if really useful! Brilliant.

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

    The final part of your tutorial saved me from a big problem, thanks, you taught me so much!

  • @ThourCS2
    @ThourCS2 2 года назад +9

    Breaking down tutorials in components this way is the way to go.
    Thank you so much for this.

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

    You are amazing! Thanks for simplifying web dev in such a clear way!

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

    Searched this morning "AlpineJS router" and Kyle released this video 5 hours later 🤔. Thank you so much for the first router solution. I am amazed at how these things are so easy to you

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

    I don't know if you know this, but your content saves lives.
    Thank you so much!

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

    Great video bud. Really nailed the params of an exercise I am working on for a bootcamp with only a little bit of adjustment. Subbed today so look forward to see what you release in the future!

  • @krishgarg2806
    @krishgarg2806 2 года назад +180

    Just for info: There is a NavLink component in react-router which will add "active" class if that link is currently active automatically. Saves some boilerplate code!

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

      Hey, I just found out about NavLink. What do you think its usecases?

    • @terragady
      @terragady 2 года назад +18

      @@jaysongoku2274 obviously nav bar items :D

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

      I was about to say the same thing

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

      activeClassName was deprecated in react-router-dom v.6

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

      @@dave6012 you use an inline function passed as value of a prop instead

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

    Thanks Kyle! I was working on my Company's official page and this video saved my day!

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

    Easy to follow along, and I like you show how to route with and without react-router-dom. Thanks for the tutorial.

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

    Thank You so much, was trying different docs and couldn't make it work, Finally found your video and made it done

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

    Thanks so much bro, you are helping me so much on my first project as an intern, keep going bro and i always will be your subscriber.

  • @rajireddyaleti6346
    @rajireddyaleti6346 2 года назад +8

    Hey Kyle, I'm a fan of yours. I like the way you make the content much simpler to understand.
    Can you start some Javascript(React) tooling-related videos to make them more understandable? I don't know most of the things why we need some libs as dependencies and soon in a while in 2yrs to 3yrs they are deprecating/outdated

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

    Thank you so much, it was exactly what I was looking for. What a great tutorial!

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

    Thank you, I have learned a lot of things from today's video. Good luck with your work.

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

    Excellent tutorial, helped a lot with my react website nav bar menu.

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

    This came at the right time! Thanks buddy!

  • @CrystalButterfly_Sadhanad
    @CrystalButterfly_Sadhanad 22 дня назад

    I am a beginner for using react. Your explanation helps me a lot.

  • @merabet.faycal
    @merabet.faycal 2 года назад +1

    easy and great as always , Thank you !

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

    Bro Thanks a lot this is what I've been looking for.

  • @memmuw
    @memmuw 8 месяцев назад

    Thank you brother, router was doing my head in.

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

    Thank You VERY VERY much. Great explanation. U are a gifted teacher and thanks one more time

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

    You are really helping me with react !

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

    Thankyou so much i was stuck on this for hours 😭😭

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

    Thanks a lot. after watcing your amazing learning video, i am able to resolve problem related to React Router.
    once again, Thanks a lot..........................

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

    Excellent vid, really clear and help[ed me fix a problem that I'd been battling with all day :-)

  • @Babisimo
    @Babisimo 2 года назад +3

    ty for simplifying the web for me

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

    Thank you so much for the video. It really helped me with my assingment.

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

    Finally, I've been waiting for a new video to come. What time do you post videos? (2d, 5d, 1w or something else)

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

    Keep up the great work!!

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

    Thanks for this knowledge!

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

    Thank you for sharing your knowledge

  • @firstdbzmaker
    @firstdbzmaker 8 месяцев назад

    I'm a fan of the teaching style :D

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

    Interesting how you have the same ideas I have, like organizing the components the router references as "pages".

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

    actual goat video only making this comment to help u in the algorithm cause u deserve it

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

    A few more that kind of video and i'll fall in love with React)

  • @empoweredsouls-relaxingmus6074
    @empoweredsouls-relaxingmus6074 2 года назад

    Thankyou so much you made my day sir

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

    Nice work ✌️

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

    Works, thanks!

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

    Thank you so much for your video it helped me out alot.

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

    Thanks a lot for this tutorial

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

    This saved me!! thank you

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

    How would you organize a multi page react app? I've seen you've separated the pages in a folder. What about components of these pages? CSS and all the good stuff?

  • @utvikler-no
    @utvikler-no Год назад

    you are a legend! Thanks!

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

    Great tutorial

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

    Thank you great video. Your a machine! Appreciate the information
    Even Your hair is even doing 100 km/hr.
    Mine does 30 km/hr like a kids school zone! Just like my coding skills.

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

    Good job!

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

    great job bro

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

    Hi, can you make a video of vanilla js routing? great videos!

  • @SaliAalaNabiyak
    @SaliAalaNabiyak 10 месяцев назад +3

    for the hook to get the current locatin you can just use one hook it is : useLocation()
    it's gonna return an obj containing the pathname which we are looking for so the after importing the hook your code should look like this :
    const location = useLocation()
    let path = location.pathname

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

      I'm sure he knows that, but you can't give away too many trade secrets in a free video.

  • @ethiocode298
    @ethiocode298 2 года назад +13

    I think we can use NavLink instead of Link for active state

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

    crazy good video !

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

    can you also use something like component={Home} when you write the routers?

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

    Thank you! This course was very useful for me - really nice :) I consider to change a small PHP app with Mysql DB to React-app for a better frontend. The only thing that trouble me is, that I can do no POST requests (e.g. for mail) to PHP scripts without using php://input thing. Would you advise to do this rather with javascript XHR-Request / Promises than php://input?

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

      Hello. You can use React JS for the front end and connect it to a PHP framework like Laravel for the backend since you’re already comfortable with PHP.
      You have options, so you can connect your react front end framework to almost any backend for POST requests and CURD, like express & node js; Laravel; or Django for example.

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

    Omg thank you so much

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

    Thank you big boss

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

    great video thx

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

    Thanks Kyle.

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

    awesome thanks

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

    Great 👍

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

    Thank you

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

    please make more videos on React

  • @Smurfis
    @Smurfis 18 дней назад

    Thank you for show-casing this as we can now use this to create an amazing display system perhaps you could make it more of a hamburger menu! Thank you!

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

    Thanks kyle

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

    Thanks, I love your angel hair. Keep it up !

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

    thank you

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

    This is a great video and tutorial! However, is a way where you can transfer data between these pages like if someone clicks a link on your pricing screen it brings it to a new screen to pay with the payment plan selected

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

    Please make a video on nested routes

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

    You're the GOAT 🙌🏽

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

    thanks for the video baby

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

    Thanks Chief, I have been struggling to find the reason why i'm getting a blank white page for two weeks now and i just found out i didn't add the BrowserRouter into the index.tsx root render function

  • @76ers
    @76ers 2 года назад

    How does node/npm run when you transfer/ftp the files to your web hosting?

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

    Does it create an or changes the html content of the page?

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

    Hello! thank you for this tutorial but I have one problem, when I add tasks on my first nav (todotask) and then I go to my second nav (timer) and then I go back to the first nav, it will reloaded and the added task is gone. can you help me what can i do to fix this? thank you!

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

    Could you make tutorial video on React unit testing ?

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

    Thanks!

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

    i love u bro thanks a lot

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

    how do you use this concept with a nav list from data? Am I supposed to know all of the links ahead of time to create routes?

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

    Kyle, I have a problem. I am hosting my website with firebase the navbar works awesome but if I try to write the url it sends me to the 404 page. How I can make it when I write a url with the page to load automaticaly??

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

    hello Kyle! Hope you are fine i wanted to ask that this code can be written in Notepad ++ ?

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

    how does the mavbar re-render? when you click on the Link, and it's color changes

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

    best practice react folder structure and state management sir

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

    What do you mean by active state? What are the differences when you implement it so that it is in such a state compared to the previous routing implementation without react router?

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

      Nevermind, I now understand it as allowing the active class concept.

  • @NahidHasan-xp1cl
    @NahidHasan-xp1cl Год назад

    Love You Boss

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

    Can you make a video about blazor?

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

    Can you do the same concept but in React Native?

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

    Can u plz create a web development guide for 2022 as u created in 2021 ….thanks in advance

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

    How would I implement this so that if on landing page the navbar is actually different then all the other pages? (I want the landing page not to have the title in the left corner but other pages will, and it will bring user back to landing page).

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

    Show us what gear you use

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

    Hi Kyle! Can you make Microsoft windows loading animation?

  • @j.villasmil9575
    @j.villasmil9575 Год назад

    What if I don't want to show the nav in a specific page, like the login for example?

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

    In my case I have buttons I want to put in the header. Any ideas?

  • @B.O.L.A
    @B.O.L.A Год назад

    Hi I don't know if you're listening I am trying to create a navbar inside an exisiting react app are you able to assist ?

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

    I know it's not the goal for this video, but you should make a video on how to make a responsive React navbar as it's one of the things I struggled when I started.

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

      This is currently me

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

    I never these hooks existed, normally I would use the useLocation hook, and the the location.pathname.. then use said pathname to compare if it matches to the target pathname to add active classes..
    Well, at least I learnt something new.. thanks

  • @bisbireto303
    @bisbireto303 8 месяцев назад

    Hello! I am new to React, I am creating a website with a pathname like: where I compare my state with my URL. Can this tutorial be helpful?

  • @8ack2Lobby
    @8ack2Lobby 2 года назад

    05:00 can anyone clear this concept? Why active class have to go above hover for it to work?