The Better Way to do Loading States in React

The Better Way to do Loading States in React

Josh tried coding

8 месяцев назад

78,762 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@ThanHtutZaw3
@ThanHtutZaw3 - 27.11.2023 16:35

But it won't get latest like count . Every click success or error should update latest like count from DB because other user will like the post anytime .

Ответить
@clemensjanes8998
@clemensjanes8998 - 21.11.2023 00:59

Absolutely amazing video. Fast paced, but clear and understandable. Keep up the good work ❤

Ответить
@stf8375
@stf8375 - 25.10.2023 02:45

you teach me something, thanks !!

Ответить
@bhargabdhungel9341
@bhargabdhungel9341 - 24.10.2023 19:53

ok

Ответить
@bibahbibah5108
@bibahbibah5108 - 18.10.2023 15:53

after seeing this i don't recommend optimistic method it's very tricky 😂 it make a very simple code to hell, the bests practices are based on simplicity

Ответить
@mdmathewdc
@mdmathewdc - 15.10.2023 03:10

How do you do the animation of the code snippets?

Ответить
@Mortada_DEV
@Mortada_DEV - 14.10.2023 13:40

Please Please Pretty Please, add chapters and timestamps to your videos. This is the only thing that's missing in the great content you provide.

Ответить
@KellenProctor
@KellenProctor - 12.10.2023 21:46

Literally perfect timing! Was just dealing with this issue for a checkbox that takes waaaay to long to update. Excellent content!

Ответить
@oliverquixchan
@oliverquixchan - 12.10.2023 17:46

is there a particular reason you chose react query over swc?

Ответить
@mknmkn2222
@mknmkn2222 - 12.10.2023 15:41

sdfsdf testing

Ответить
@shadowpony9243
@shadowpony9243 - 12.10.2023 11:16

epic!

Ответить
@ethioapps836
@ethioapps836 - 12.10.2023 10:30

josh i really like your contents man. keep up dude. you are leveling up my skills constantly with you engaging and interesting contents . big respect dude

Ответить
@MrBlazzerBoy
@MrBlazzerBoy - 11.10.2023 08:53

Video is way too fast.

Ответить
@ProductDesignTalk
@ProductDesignTalk - 10.10.2023 22:28

I forgot to press the like button so I came back to press it 1.4K times — sub’d

Ответить
@irfansaeedkhan7242
@irfansaeedkhan7242 - 10.10.2023 21:21

why not use swr ? which one is better swr or react query

Ответить
@versaleyoutubevanced8647
@versaleyoutubevanced8647 - 10.10.2023 18:48

I remember I did something like that in some of my previous projects.

I add in the query data cache, the new post, with "mocked" id and createdAt since they should've come from backend.

Then on the onSuccess callback, I get the new post info, and change the mocked post properties with the backend ones.

May not cover up all the cases, but was a valid approach back then

Ответить
@nikhil8279
@nikhil8279 - 10.10.2023 15:10

hey can u please add all your Big projects in a dedicated playlist 💗

Ответить
@DoSmth
@DoSmth - 10.10.2023 13:22

Can we do same things in Solid js?

Ответить
@nikitachernenko3774
@nikitachernenko3774 - 10.10.2023 11:40

Hi! nice video! Is there something special you use to show the code in vs code? or do you just go through pressing ctrl+shit+z?

Ответить
@hithakcer
@hithakcer - 10.10.2023 11:39

Implemented Optimistic updates using React Query just last week. Pretty awesome.

Ответить
@girijeshthodupunuri1300
@girijeshthodupunuri1300 - 10.10.2023 11:20

can you link me the repo with the react query code? I really want to fully grasp the use of it!

Ответить
@antopolskiy
@antopolskiy - 10.10.2023 10:21

do I understand correctly that with Firestore onSnaphot queries, you get optimistic updates out of the box?

Ответить
@sburke0708
@sburke0708 - 09.10.2023 21:34

The title and the thumbnail are misleading of what this video is actually about

Ответить
@mohammadghahri7230
@mohammadghahri7230 - 09.10.2023 20:10

it's a neat trick for making the ux better,
but if there's a connection problem or user immediately close the browser it would cause a problem

Ответить
@user-zx8cl1qg8u
@user-zx8cl1qg8u - 09.10.2023 19:46

Will this work with trpc?

Ответить
@sujjee
@sujjee - 09.10.2023 17:19

hey josh next long video on netflix clone?? with all new and latest nextjs 13 , tRPC and prisma

Ответить
@BandosLP
@BandosLP - 09.10.2023 16:23

Hi Josh, can you release the source code for this?:)

Ответить
@asadmalik5075
@asadmalik5075 - 09.10.2023 13:39

Can you make a detailed tutorial on real life usage of react query along side with redux ? any advanced todo app something like that ?

Ответить
@taquanminhlong
@taquanminhlong - 09.10.2023 13:38

this already built in for Remix 😂

Ответить
@Frontend_Ed
@Frontend_Ed - 09.10.2023 13:00

Love this 😍 how do you make the smooth code addition animations? 👀

Ответить
@MrEnsiferum77
@MrEnsiferum77 - 09.10.2023 11:08

The optmisic update, it's a bit problematic and u need to know what u are doing... In case of RQ optimistic update, react doesn't rerender, which can be problematic many times....

Ответить
@SaadKhan-rl4qy
@SaadKhan-rl4qy - 09.10.2023 08:14

Man just loved your content. I don't know how you know what I was looking for.

Ответить
@meka4996
@meka4996 - 09.10.2023 07:40

Very useful! Thanks

Ответить
@yanisoulhaci3369
@yanisoulhaci3369 - 09.10.2023 05:08

I love your content Josh, very unfortunate I am very bad at English I have to spend 20min on a 10min video

Ответить
@gregthomas5887
@gregthomas5887 - 09.10.2023 04:45

what do you use to animate the code examples? (2)

Ответить
@fiqihalfito8776
@fiqihalfito8776 - 09.10.2023 04:30

Josh tried liking his video

Ответить
@mikelCold
@mikelCold - 09.10.2023 04:26

Love it. Always great to get a real take on a the experimental API instead of people just demoing the docs.

Ответить
@mustafa.wael-dev
@mustafa.wael-dev - 09.10.2023 01:33

what is the best way to use react state Management and react query with next 13 and server component, could you share a video with the best implementation or starter?🙂

Ответить
@rhkina
@rhkina - 08.10.2023 23:13

Too complicated! Isn't there a simpler solution?

Ответить
@gosnooky
@gosnooky - 08.10.2023 22:43

I love ReactQuery.

Ответить
@iPankBMW
@iPankBMW - 08.10.2023 22:26

what do you use to animate the code examples?

Ответить
@animegeek-011
@animegeek-011 - 08.10.2023 22:17

OnError, OnSuccess, OnSettle
are all deprecated by now according to the docs.
Luckly, you can achieve the same results using custom hooks that returns the returned value of useQuery, or simply use your own useEffect.

Ответить
@fennecbesixdouze1794
@fennecbesixdouze1794 - 08.10.2023 22:14

If your recommended way of handling one of the most common aspects of your application involves doing something like awaiting a call to cancelQueries to prevent your framework from doing what it wants to do, you know you're doing something very wrong.

Couldn't think of a worse way of doing this.

There are even more problems in this video: resetting the likes to the previous likes likely violates your business logic. Just because some error was returned at some point in your request doesn't mean that the likes are equal to what they were before you clicked "like".

In this specific example of a like counter, someone else could be hitting "like" and it could increment for that reason. In other examples, an error might occur handling the connection but the like you submitted very well could have gone through already. Assuming that the application remains in the previous state on an error is almost never correct business logic.

Ответить
@0xtz_
@0xtz_ - 08.10.2023 21:52

I like using swr only for this 😂 now less swr

Ответить
@eesaaphilips9271
@eesaaphilips9271 - 08.10.2023 21:45

Nice video. It seems to me like doing it yourself is just as simple as using a library (I do it myself in jQuery and Solidjs). I don't see much value in react query at all

Ответить
@Monstermash355
@Monstermash355 - 08.10.2023 21:17

Would you always use optimistic updates instead of loaders? I mean, where is the limit if there is one?

Also, is there a way to do this without react query (with server actions)? Because I feel it's the future, so react query kind of overlaps but I might be wrong

Ответить
@blazi_0
@blazi_0 - 08.10.2023 21:10

Another way i use sometimes, i store the data inside jotai store so ill use the react states to update it very easily from anywhere when mutating any data

Ответить
@ayushtiwari9343
@ayushtiwari9343 - 08.10.2023 21:07

This was awesome loved it ❤.

Ответить