Тёмный

Infinite Scroll And Filters With React Query 

Watch and Learn
Подписаться 34 тыс.
Просмотров 26 тыс.
50% 1

In this video I'm going to show you how I implemented Infinite Scroll and filters on my new website.
So I’m currently working on a new site for Watch and Learn, the first MVP is already done and should be live soon, once I decide what I will use for hosting the frontend of the site. The stack that I’m using for the site is October CMS for the backend.
And of course the frontend is Next.js with TypeScript and Tailwind CSS that uses Just in Time compilation. Which turned out to be a really nice way of building the frontend.
The reason I’m using October CMS for the backend is that my site has been running on October for a few years now and all my videos and data are there, and I don’t wanna waste time with transfering all of that data to another CMS because October is doing the job it needs to just fine.
Also since October is made with Laravel it makes it pretty easy to create your own APIs that you can connect to with something like Next.js, Vue, React and so on.
So I was thinking about how to make pagination for “all videos” page, Currently it’s a classical pagination that you need to click on to get to the next set of items.
In my opinion this is not a very good pattern because normal pagination gives you redundant info, what I mean by that, is that the pages of a list don’t actually mean anything to the user, the user won’t know what to expect on the 2nd page, and what to expect on the 10th page.
So it’s better to just serve a list that the user can scroll through without any required interaction to see the next items in the list.
This is a familiar pattern that you can see on many apps and platforms like Facebook, Instagram, RU-vid and so on.
And if you include #filters with infinite scrolling this makes a very nice combo. Because when the user actually filters something he or she will have a general idea of what to expect in terms of content that will be returned.
So for my site I decided to go with Infinte Scroll because of the reasons mentioned earlier.
Now [I already showed you how to make infinite scrolling with Infinite Scroll Component](watch-learn.com/making-websit...) in the previous video, but that component will make it hard for us to include filters to our list of items, because it is primarily made to do only infinite scrolling.
So on my site I decided to go with #React #Query which enables me to have Infinte Scrolling, Filtering and also everything else that React Query offers in terms of data fetching - like caching, content invalidation and so on.
In this video I’m going to show you how I did this.
Scroll Icon by www.freepik.com from www.flaticon.com/
Code used in this video
bit.ly/34wPQie
----------------------------------------------------------------------------------------------
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. You can check it out here: bit.ly/3qdjIc5​​​​​
------------------------------------------------------------------------------------------------
You can support my work on Patreon
/ watchlearn
Follow me on Social Media
Github: github.com/ivandoric
Twitter: / ivan_doric
Instagram: / watchlearntuts
Facebook: / watchlearntutorials

Опубликовано:

 

29 май 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 15   
@TH3G4N5T3R
@TH3G4N5T3R 3 года назад
Thanks you so much, it helped me a lot!
@WatchandLearnTutorials
@WatchandLearnTutorials 3 года назад
Glad I could help 😀
@mustafawael8617
@mustafawael8617 3 года назад
First of all, thanks for your efforts and sharing your knowledge with us 😊❤️, Could you create another video about how to use strapi graphql instead of REST api with the same react-query filtering and infinite scroll functionality ☺️☺️
@WatchandLearnTutorials
@WatchandLearnTutorials 3 года назад
I will think about it, the problem with that is that then I would have to explain what is GraphQL how to use it etc. Maybe I make a mini series about Strapi and GraphQL and include that video there. But anyway thanks for watching and thanks for the suggestion 😀
@alecl6784
@alecl6784 3 года назад
@@WatchandLearnTutorials Yes Please! I came to ask the same question about strapi graphql and useinfinitequery. I was able to get graphql and react-query working with the info from your react-query filtering video, but I'm stuck with infinite scroll.
@WatchandLearnTutorials
@WatchandLearnTutorials 3 года назад
@@alecl6784 Hmmm, I would guess it would be even easier with GraphQL because with it you can define your schema so you would be getting correctly formatted data right away. Also keep in mind that I'm not using Strapi in this video, but October CMS, so you can't follow this exactly.
@GamingYT-cf3be
@GamingYT-cf3be 2 года назад
Can with do it with reddit API? Because in reddit API pagination working on after before method in URL please suggest how to do infinite scroll with reddit API.
@kathiyavadi_sk
@kathiyavadi_sk 10 месяцев назад
my problem is related to pages. i have a listing page which use getserversideprops function and i click on one of the list i go to detail page which is also use getderversideprops function. my listing page has a scroll function which is update list based on scroll. when i scroll 5 to 6 time and click one of the list and hit browser back button i lost my list so how i maintain my listing data as it is that i'm not lost. any one help me with this !!
@peter042
@peter042 2 года назад
Hi, how can i replace the october code? I'm trying but I cant solve this, and its so painful. Btw i wanna get items from mongodb with nextjs, and load them with infinity scroll, filters, and sorting. But I cant rewrite that code you did with october xd. Pls help me :'c
@WatchandLearnTutorials
@WatchandLearnTutorials 2 года назад
The code would be a little bit different depending on your data source. When using CMS like October you usually get the data that you need to make infinite scroll, like total number of pages, how many items you get per page, on which page you are currently, what is the next page, are you on first or last page etc. Now I don't know how this works for MongoDB I never used it so I don't know how to help you with that. Maybe one of the results from this Google search can help you. www.google.com/search?q=mongodb+infinite+scroll&oq=mongodb+infinite+scroll&aqs=chrome..69i57.5112j0j1&sourceid=chrome&ie=UTF-8
@tomphung4217
@tomphung4217 2 года назад
Hi, how do I use pagination with strapi and react query? Since strapi does not provide pagination
@WatchandLearnTutorials
@WatchandLearnTutorials 2 года назад
Strapi does provide pagination, and I have video about it: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ZG8VBfBDQZQ.html
@iamabhirupdatta
@iamabhirupdatta Год назад
any way we could use post request
@neliobila
@neliobila Год назад
The code link is broken
@WatchandLearnTutorials
@WatchandLearnTutorials Год назад
Works fine. Try this: gist.github.com/ivandoric/2f770c7b8c165d76a431e34c98312d76
Далее
Learn Intersection Observer In 15 Minutes
15:32
Просмотров 320 тыс.
Let's Checkout... Directus 9
39:21
Просмотров 17 тыс.
Five Clever Hacks for React-Query and SWR
40:09
Просмотров 58 тыс.
React Query Makes Writing React Code 200% Better
13:54
Просмотров 178 тыс.
Turning bad React code into senior React code
13:10
Просмотров 86 тыс.
Top 10 CSS One Liners That Will Blow Your Mind
13:34
Просмотров 913 тыс.
Google Releases AI AGENT BUILDER! 🤖 Worth The Wait?
34:21
Learn React Query In 50 Minutes
51:09
Просмотров 272 тыс.
6 Levels of Thinking Every Student MUST Master
17:12
Просмотров 927 тыс.
Cool Tools I’ve Been Using Lately
23:11
Просмотров 186 тыс.