The Better Way to Manage React State

The Better Way to Manage React State

Josh tried coding

17 часов назад

15,329 Просмотров

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


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

@sad_man_no_talent
@sad_man_no_talent - 04.11.2024 19:49

SHITTY. guys use zustand

Ответить
@devkasunlakshitha
@devkasunlakshitha - 04.11.2024 19:50

Brother, Thanks a lot for this! Really cool and useful!

Ответить
@vasyaqwe2087
@vasyaqwe2087 - 04.11.2024 19:57

or try tanstack router. it's mind-blowing how good it is at this stuff

Ответить
@Noam-Bahar
@Noam-Bahar - 04.11.2024 20:06

The package is called nuqs

Ответить
@Gohealt
@Gohealt - 04.11.2024 20:22

It’s 2024 and we are still seeing state management in react? Jesus!!

Ответить
@salihyil2
@salihyil2 - 04.11.2024 20:23

npm i nuqs

Ответить
@Paul_Marek
@Paul_Marek - 04.11.2024 20:31

How did you get it to create a hash for some of the content that you wanted to make obscured/private in the url?

Ответить
@tomcat1112k
@tomcat1112k - 04.11.2024 20:31

YO! subscribed

Ответить
@TianYuanEX
@TianYuanEX - 04.11.2024 20:32

Just use tanstack router tbh...

This is cool and all, but the moment you need more complicated state to be stored in URL, or (god forbid) dynamic params, this library will become more of an obstacle than help.

Ответить
@rand0mtv660
@rand0mtv660 - 04.11.2024 20:34

I've been using nuqs for few months now and it has been an absolute blessing to work with. I discovered it just before I had to work on a feature that had to deeplink multiple selected filters on a page and I just saved a bunch of time with this library because I didn't have to implement all this stuff by myself.

Ответить
@curiousprogrammer90
@curiousprogrammer90 - 04.11.2024 20:36

How this works under the hood though? Does it do router.replace for every change?

Ответить
@cant_sleeeep
@cant_sleeeep - 04.11.2024 20:40

just use react query button

Ответить
@guillemgarcia3630
@guillemgarcia3630 - 04.11.2024 20:44

so, a wrapper around window.history.replaceState?

Ответить
@ts8960
@ts8960 - 04.11.2024 21:07

who the hell needs state management? keep your app simple ffs. Developers always overcomplicating things

Ответить
@Hugos68
@Hugos68 - 04.11.2024 21:11

We're developing backwards if storing state in the URL is rediscovered 😄Great video though!

Ответить
@siya.abc123
@siya.abc123 - 04.11.2024 21:19

Yo!

If it changes the url in real time on input, you're gonna need to debounce that!

Ответить
@Blorvax
@Blorvax - 04.11.2024 21:20

I wrote and used the hook and named it useFilter, but this nuqs implementation is much better option. Love it. <3

Ответить
@AbhiShake-pl3cf
@AbhiShake-pl3cf - 04.11.2024 21:34

Misleading title..

Ответить
@mahmoudwalid1703
@mahmoudwalid1703 - 04.11.2024 21:41

This package is very useful and time-saving. I will use it in my projects

Ответить
@dragos.cojocaru
@dragos.cojocaru - 04.11.2024 21:51

These guys reinvented react router

Ответить
@franky47
@franky47 - 04.11.2024 21:53

Thanks Josh! (I'm the author of nuqs). Most people pronounce it "nucks", I pronounce it "nukes" but I'm getting around to it. AMA.

Ответить
@nklpn
@nklpn - 04.11.2024 22:11

are those the new starlight airpods? looks great!

Ответить
@AbouAnia
@AbouAnia - 04.11.2024 22:43

Php again

Ответить
@teenspirit8714
@teenspirit8714 - 04.11.2024 22:46

someone tell him about preact signals, with can be used in react

Ответить
@saissevictor
@saissevictor - 04.11.2024 23:06

checked this in the midday repo, amazing work from frank

Ответить
@bioburden
@bioburden - 04.11.2024 23:17

Could be nice to pair with React Query too

Ответить
@ErmandDurro
@ErmandDurro - 04.11.2024 23:38

Wow so cool. Thank you Josh for showing this 😃

Ответить
@dejoma.
@dejoma. - 05.11.2024 00:11

Bruhhhh I literally coded this myself just a month ago 😂 all that for nothing ahaha even the transition and helper functions “parseIntPrUndefined” kinda things.

Ответить
@DanZ-fq2qs
@DanZ-fq2qs - 05.11.2024 00:13

try this? NO

Ответить
@makerKID5
@makerKID5 - 05.11.2024 00:32

Josh, I just want to thank you. You're my number #1 source for keeping up to date in this ever changing behemoth we call tech. You're the best. I saw you're video yesterday and I just want you to know how much you're helping others. I'd watch anything you put out.

Ответить
@ahmedalsumairi5482
@ahmedalsumairi5482 - 05.11.2024 00:36

The most horrible thing i faced in react is 'useState'

Ответить
@The.Meshhh
@The.Meshhh - 05.11.2024 00:41

Wondering what tthe example Use -Cases for this might be

Ответить
@campos_victor
@campos_victor - 05.11.2024 01:02

Another cool feature you didn’t mention is createSearchParamsCache, which allows you to define a schema and share your search parameters with nested server components.

Ответить
@victorm3193
@victorm3193 - 05.11.2024 02:25

Hi Josh. Can you do a deep dive in unit testing Nextjs apps?

Ответить
@umardev500
@umardev500 - 05.11.2024 02:38

You can't do that always. That URL bar has limited character long

Ответить
@virtual5754
@virtual5754 - 05.11.2024 03:31

Have been using it since next 13. Main benefit of this library is that it allows to abstract updating url without extra requests to server. Next team, are you for real? It has been two years since release of app router, where is native shallow refresh?

Ответить
@mzafarr
@mzafarr - 05.11.2024 04:15

Such short videos are really useful

Ответить
@raves_r3177
@raves_r3177 - 05.11.2024 04:27

or just use tanstack router

Ответить
@ChiefORZ92
@ChiefORZ92 - 05.11.2024 05:03

I used it two weeks ago on a project, problem is when you try to update multiple values at the same time you will get a race condition and a unsaved state unfortunately...

Ответить
@debarkamondal6406
@debarkamondal6406 - 05.11.2024 07:13

I don't understand why is this a library? Should be pretty easy to push things into the URL. On load pull in the the query params and push it to local or global state. For updating write a simple function that pushes the data to both the URL and the state. Why install yet another library for that simple task? I would keep a single source or truth by default and do this sycing only when needed. I don't use anything like redux unless absolutely required. What do you think? I would love your opnion.

Ответить
@itsaysthat2502
@itsaysthat2502 - 05.11.2024 08:48

Yo sir
Make a video on how u started coding from zero and how u got the job.

And btw don't ignore my comment. Else I'll share your details with fbi

Ответить
@lingarajsahoo3583
@lingarajsahoo3583 - 05.11.2024 08:55

cool

Ответить
@LlamaPony
@LlamaPony - 05.11.2024 09:19

lol setting up query params always been a hassle, this makes it as easy as squeezing a lemon

Ответить
@essayvlog
@essayvlog - 05.11.2024 09:40

Thanks for letting us know the amazing library

Ответить
@Skorupa9
@Skorupa9 - 05.11.2024 09:47

Really? xD Like you can't just create few lines hook for that? xD

Ответить
@afolabidamilare8756
@afolabidamilare8756 - 05.11.2024 09:58

Wow

Ответить
@authentictr8807
@authentictr8807 - 05.11.2024 09:59

perfect for a QR code system. hey ChatGPT, suggest business ideas using this.

Ответить
@gvsakhil143
@gvsakhil143 - 05.11.2024 10:14

Its very useful, thanks a lot dude

Ответить
@firmankhoirilrahmatullah4631
@firmankhoirilrahmatullah4631 - 05.11.2024 10:44

looks like useSearchParams but more simple 🤔

Ответить