Simple Frontend Pagination | React

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

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

  • @michelezucca5819
    @michelezucca5819 3 ปีที่แล้ว +80

    This is like the easiest and most simple way of paginating with React I've seen, much better than many other tutorials, hats off Brad you're always the man

  • @matthiasmatanda4295
    @matthiasmatanda4295 2 หลายเดือนก่อน +1

    I watched this in 2024, still a valid tutorial, thanks God for Brand Traversy Media

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

    Even in 2022, This Tutorial is still REALLY HELPFUL!
    Brad, your videos are such a HUGE help. THANK YOU!!

  • @AbdulelahAlJeffery
    @AbdulelahAlJeffery 5 ปีที่แล้ว +154

    Traversy Media is the new Khan Academy for all things web .. excellent job Brad!

    • @romanpabianczyk8870
      @romanpabianczyk8870 4 ปีที่แล้ว

      Bullshit. This code doesn't work for me.

    • @avthreek
      @avthreek 4 ปีที่แล้ว +3

      @@romanpabianczyk8870 yeah, it only does for small amount of results. Not for thousands as Brad said in the end.

    • @yusuffakhreddin263
      @yusuffakhreddin263 4 ปีที่แล้ว

      @@avthreek do you know why ?

    • @avthreek
      @avthreek 4 ปีที่แล้ว +6

      @@yusuffakhreddin263 it is easier to fetch small amount of results when needed, rather than getting ALL the results and paginating them on the front end.
      For example my table have millions of rows and those rows have even more results attached in foreign tables. So loading them All is very expensive in a loading time and size and it is also unnecessary if user wants to get for example second page results and he will never reach third page. For such large data we paginate on the back end and retrieve pieces of data.

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

      @@avthreek thank you

  • @GabrielRamirez-rm7qh
    @GabrielRamirez-rm7qh 2 ปีที่แล้ว +49

    PSA: If using this pagination component inside of a route ,the anchor tag will navigate you away from your route and throw an error. The "!# href is a hack to trigger javascript while avoiding side effects. It can work in some cases but is not semantically correct . The fix for this, and semantically correct option would be to simply remove the href attribute and use a button tag instead of an anchor tag.

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

      you saved my fucking life i was having a fucking meltdown

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

      Thanks

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

      Nice tip bro, helped me out with that one appreciate it!

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

      You can also try href="#!" but as you've said, it's still not semantically correct.

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

      U U a a real one thanks

  • @oussemamiled4545
    @oussemamiled4545 5 ปีที่แล้ว +29

    brad, i really don't have much time but when you post a video, like it's a must watch

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

    Finally I saw i pagination tutorials that doesn't use a paginated library. Perfect to learn how that really works with actual code.

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

    Dude, I'm putting an altar of you next to my desk, it's official. U are such a great teacher, thanks for all the great content.

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

    This was possibly the best coding tutorial I've ever watched. I've been browsing google for hours just trying to find a decent tutorial and this was easily the best, super straight and to the point and great at explaining everything thats going on. Thank You!

  • @farhan787
    @farhan787 4 ปีที่แล้ว +12

    I can't thank you enough Brad, THAAAAAANNNNNNKKKKKKKKKKKSSSSSSSSSSS. a lot for this, I needed to implement it in one of my project on my new job and I'm not good at frontend but because of you, I was able to implement it ❤️❤️❤️❤️

  • @mekabeka23
    @mekabeka23 4 ปีที่แล้ว +18

    This was the simplest tutorial I've seen all day on pagination. Thank you. I understood 100% all while the simple way to use hooks. You're awesome.

    • @Maratreason
      @Maratreason 3 ปีที่แล้ว

      so do I :)
      Thank you man!

    • @ridz4912
      @ridz4912 3 ปีที่แล้ว

      I agree 100%

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

    I began taking his class in udemy about a month ago and I will take his courses ever since. great teacher of mine

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

    You actually listened to the request from your users. You really care about your viewers! 😃

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

    Great video TM. You explain things so clearly with additional 'why we do this...' thrown in which gives context rather than just running through lines of code. Thanks !

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

    Thank you, Brad! This tutorial was extremely useful! I was struggling with Material UI as beginner in React but you made building pagination to look so easy and clean! You thought me so much and I am very grateful to everything you do for us! Much love!

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

    Who dislikes this amazing video? This is very very helpful. I just love it.

    • @emreaka3965
      @emreaka3965 3 ปีที่แล้ว

      They should comment that why did not they dislike the video for. ^^

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

    Thank you so much Brad. I was the guy who asked for this video..Thank you again for your work..you are my god and my inspiration

  • @denniszenanywhere
    @denniszenanywhere 5 ปีที่แล้ว +4

    Waking up with a new Brad video is the best. Thanks!

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

    Okay this one really helped, thank you. Even after 4 years, your content is helpful

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

    Very good tutorial ! for the , i've found that href="!#" doesn't work, it does with href="#!". Maybe it's because i don't have bootstrap

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

      Im thank ful that i see your comment mine not working to when i use "!#"

  • @igoralves1925
    @igoralves1925 4 ปีที่แล้ว

    i've searching about it for a few hours, I watched some video and read some blogs but your content was the only one that really helped me . Thanks !

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

    watched this video, uses pure react to develop pagination, one of the best concept using only use state hooks, very usefil

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

    EVEN IN 2023 this was helpful with a bit tweaks from newer hooks that reacts has now this is great thanks!

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

      dont mind my grammar offl the ZA

  • @RobertTodar
    @RobertTodar 5 ปีที่แล้ว +5

    I love these short and simple lessons. I learned so much from this. Thank you!

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

    Dude you're a G. This is by far the cleanest way i've seen so far

  • @user-wt9xm7pj7i
    @user-wt9xm7pj7i 4 ปีที่แล้ว +5

    but there is a small question - how to make the first link active when the page is loaded, since the page reloads on the first click

  • @pam_prunelle1693
    @pam_prunelle1693 4 ปีที่แล้ว

    With your tutos, I progressed, raised my level. A big thank-you
    Brad Traversy

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

    oh thank God finally I find the best video about pagination

  • @hn031
    @hn031 4 ปีที่แล้ว

    Thanks man. I'm at point in a project where I had to chose which pagination to use. The data coming from the backend is already paginated, but I don't like that a new request had to be sent to the backend each time a new page is requested; I consider this too much load. Then I didn't want to use a package to paginate my data. What I'm left with is to learn how to do the pagination; you just helped out. Thanks a lot . You're saving tons of life and jobs.

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

    Thanks, Brad. This was my first intro to pagination. I tried another instructor but he uses 'lodash' for something you made so simple.

  • @1337-coder
    @1337-coder ปีที่แล้ว

    for anyone wondering why indexOfLastPost = currentPage * postsPerPage is valid:
    the slice method's end parameter can be greater than the array length. if this is the case (for example last page has fewer posts), slice uses the array's length as the end parameter.

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

    2023 and this tutorial is so useful! Thanks a lot

  • @marcuszierke7930
    @marcuszierke7930 5 ปีที่แล้ว

    No idea what those 12 haters have to complain about - amazing video, simple, efficient and great way of explaining.

  • @kiransurage
    @kiransurage 5 ปีที่แล้ว

    Anyone else hits the Like button as they start watching, bcuz its Brad, and u just know it's going to be awesome?

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

    Incredible tutorial :D , well explained step by step and not skipping anything, the truth has helped me a lot, thanks for the time! Greetings from Argentina.

  • @lexsemenenko
    @lexsemenenko 5 ปีที่แล้ว +4

    Thank you. Right in time. Would be more complete showing how to make pagination button active.

  • @smsibasish
    @smsibasish 5 ปีที่แล้ว +41

    Congrats Brad for 777k subscribers 😄

    • @Endrit719
      @Endrit719 3 ปีที่แล้ว

      now he has 1.29M

    • @Elon-musk-007
      @Elon-musk-007 3 ปีที่แล้ว

      @@Endrit719 now he has 1.45M

  • @yendrembamrabinchandra476
    @yendrembamrabinchandra476 5 ปีที่แล้ว +20

    Brad, please upload a tutorial Video on Data Structures and Algorithms in JS

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

      there is one in freecodecamp channel

  • @venkatasaipavanmadabathula9499
    @venkatasaipavanmadabathula9499 3 ปีที่แล้ว

    this is the simplest video on pagination that is present !!!!!

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

    Thanks a lot man, this really helped me understand how pagination works and now I have a full component I can always reuse

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

    Still relevant in 2023. React-bootstrap table needs an update with pagination. Thanks for vid.

  • @TheNikola2910
    @TheNikola2910 4 ปีที่แล้ว +3

    This helped me get a job! Thank you so much Brad!

  • @gsalazarmusic
    @gsalazarmusic 3 ปีที่แล้ว

    Dude!!! Thank you so much! My nightmares doing paginations are over!!!

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

    Echoing what everyone else is saying, this is a great tutorial. Very helpful! Thank you!

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

    Phenomenal video, that was crystal clear. Thanks for posting the code too, I'm gonna practice with the Json file. I have a react technical interview coming up so thanks so much for this.

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

    Brad is the best teacher and inspirational guy. Make this blue if you think it's true.
    Btw: thank you very much sir.

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

    This is great. I'm just getting to grips with React and hooks so this was perfect - I may even use pagination in my next project now. Thanks Brad

  • @viktoriazubchenko5428
    @viktoriazubchenko5428 3 ปีที่แล้ว

    wow! Thank you for your video, it was so helpful for me, not only as pagination tutorial, but also as a short lesson about how cool hooks are.

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

    Thanks Brad, this is a big help. One sidenote: the href attribute in the pagination component crashed my app, I'm not familiar with the exclamation mark in href="!#", when I replaced it with href="#", and everything worked fine. I read elsewhere that using anchor tags with onClick events cause unexpected behavior, so I replaced those with buttons (developer.mozilla.org/nl/docs/Web/HTML/Element/a).

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

    this video was really helpful, I saw many of them about pagination, but this is a quality content, thank you so much :D

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

    Kind of amazed by how easy this was, ty Brad!

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

    Great video! I completed this tutorial, and I am looking forward to watching a pagination lesson using the back end. Thank you!

  • @shivanimathur1356
    @shivanimathur1356 3 ปีที่แล้ว

    Thank you for making this so easy, I've been hitting my head on pagination for 3 days

  • @Mathis-zk7uq
    @Mathis-zk7uq 5 ปีที่แล้ว +3

    Thank you very much :) Can't wait for the full stack video !!!

  • @L-Wassa
    @L-Wassa 4 ปีที่แล้ว

    Traversy Media the best channel for web developers!!!

  • @brunagomesdasilva7777
    @brunagomesdasilva7777 3 ปีที่แล้ว

    Many Thanks, Brad!! It really helped me.
    Also I'd like to show how I solve my url issue.
    I changed
    paginate(number)} href="!#" className="page-link">{number}
    by
    : Add Link react-router-dom
    paginate(number)}>
    {number}

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

    Thanks Brad! SUPER USEFUL. For the full-stack, put pagination it in your MERN stack course! I will be doing that. Thanks.

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

    This is the Best and Easiest Pagination I've ever seen. Thank You Soo Much for this Wonderful video Brad. I'm Your new Subscriber

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

    Great video! But regarding the number of pages that should be generated, I don't push the pages into a new array. I just use Math.ceil() to return the number of pages. For example, one could do this:
    const pageNumbers = Math.ceil(totalPosts/postsPerPage) === 0 ? 1 : Math.ceil(totalPosts/postsPerPage);

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

    Thank you so much for the great walk-through. I was able to adapt this simple code into a table that stored all my accounts.
    The switch from front end to backend was also super easy. Just needed to pull from a server with my data and use a limit and offset for the data. The rest of the page work is done front end.

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

    This is just amazing, so simple and works like a charm!

  • @Hashmimohammed
    @Hashmimohammed 5 ปีที่แล้ว

    Transforming many lives with your work. You Rock

  • @madeinbalcony7237
    @madeinbalcony7237 4 ปีที่แล้ว

    this is worth not skipping ads. as always, thanks brad :D

  • @arifeljutviovska7672
    @arifeljutviovska7672 3 ปีที่แล้ว

    Man I love you I was searching everywhere for this and it works thank you so much

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

    very good way of pagination, it helped me a lot to set up my pagination system

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

    Amazing, been searching for something like this everywhere!
    It would be amazing would be if you could do it where you don't load then unless you click second or third page etc, only load recourses required - Just like you mentioned in your video. Thanks again!

  • @shauntonesify
    @shauntonesify 4 ปีที่แล้ว

    I love you Brad, you saved my life again on another project.

  • @zoheballadin-ys5pk
    @zoheballadin-ys5pk ปีที่แล้ว

    This method will result in slight lag when you have a lot of pages. To fix the lag, simply remove the anchor tag of the page numbers and put the onClick on the li tag .

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

    You are the best, Im taking a bow

  • @karma_yogi_42
    @karma_yogi_42 3 ปีที่แล้ว

    what a life saver!
    thanks needed this for a interview assignment!

  • @aniketa.raikwar1983
    @aniketa.raikwar1983 3 ปีที่แล้ว

    Excellent Video, Thank you so much, without this tutorial i can able to implement pagination.

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

    Thank you so much Brad! Exactly what I was looking for. This approach was super useful for my own project.

  • @md.fazlulkarim8847
    @md.fazlulkarim8847 5 ปีที่แล้ว

    In the video, you wrote the useState code and right after that, you showed us how actually state and useState are similar. That took at best two seconds. But this type of little things makes you different than thousands of content creator.
    Please consider making a short course on Algolia with react in the future? Take love...💛💛💛

  • @julielesage960
    @julielesage960 4 ปีที่แล้ว

    Perfect clear and simple, up to date code, and I love your voice ! many thanks

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

    nuhun mang, gampang kaharti.. thank you sir, it easy to understand

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

    Thank you so much. This worked for me except I also used routing (react-router-dom), so my pages don't show up for long

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

    This is an awesome video you saved me countless hours..

  • @HarshSingh-ot1jj
    @HarshSingh-ot1jj 3 ปีที่แล้ว

    This is the best video on pagination ❤️

  • @pirouz_roshanzamir
    @pirouz_roshanzamir 3 ปีที่แล้ว

    U have no idea how much time this saved me

  • @natefr0st239
    @natefr0st239 5 ปีที่แล้ว

    I liked the video before I even watch it, because I know it's gonna be a good one as any other in that channel.

  • @BadtzCarol
    @BadtzCarol 3 ปีที่แล้ว

    Thank you so much for the awesome tutorial!
    Now I have a pagination component that can use in every project

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

    omg this dude saved me life!!

  • @rodolfoleal7295
    @rodolfoleal7295 4 ปีที่แล้ว

    Just used it on my project. Thank you very much Brad!

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

    Extraordinary explanation 👌🏼👌🏼👌🏼

  • @patineira1323
    @patineira1323 4 ปีที่แล้ว

    Simple but solves the need it. Amazing your explanation, thank you so much!

  • @Kagmajn
    @Kagmajn 5 ปีที่แล้ว

    wow, you just solved my problem for my current project, well i think i have to check the full tutorial for the react

  • @ShubhamRathod-jg9gt
    @ShubhamRathod-jg9gt 5 ปีที่แล้ว +2

    Keep post more on React.js related topics (: and congratulations for 777K subscribers

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

    I love you so much, this one is so simple for newbie.

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

    Thanks buddy for the example, it is very simple and correctly explained.

  • @Rolanditou
    @Rolanditou 4 ปีที่แล้ว

    BRAD GOD BLESS YOU AND YOUR FAMILY FOR 100 GENERATIONS !!

  • @francisfernando4605
    @francisfernando4605 3 ปีที่แล้ว

    Very easy to understand. Great tutorials. Thank you so much

  • @theanhtran2595
    @theanhtran2595 5 ปีที่แล้ว +3

    I look forward to the course React-Native. Please do it on udemy. I believe many people expect this like me

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

    Thank you soo much, Brad! I really needed this. God bless you.

  • @harrisonekpobimi4764
    @harrisonekpobimi4764 5 ปีที่แล้ว

    Actually what I was thinking about last week but I have not been able to fully understand hooks. All Hail Brad T

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

    Thank you, Brad! This tutorial was Awsome.!

  • @nages1549
    @nages1549 3 ปีที่แล้ว

    Brad you are the god for many developers 🤟🤟🤟

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

    Easy and understandable explanation

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

    Awesome, clear and simple to follow.

  • @dermotsheerin5672
    @dermotsheerin5672 4 ปีที่แล้ว

    Thanks a mill Brad that was excellent.....as always you explain all steps

  • @MiguelRochaOporto
    @MiguelRochaOporto 4 ปีที่แล้ว

    Excelent! Thank you very much. Now I go implement Search in table!