React Zustand Tutorial - 6 Persist Middleware(typescript)

  Рет қаралды 7,575

Conny Gu

Conny Gu

Күн бұрын

Пікірлер: 29
@sahilshakya__
@sahilshakya__ 8 ай бұрын
Thank you Conny, learned so much.
@playwithreality
@playwithreality 3 ай бұрын
Thank you Conny, this was exactly what I needed
@emmanuelxs6143
@emmanuelxs6143 5 ай бұрын
Please what's the name of the vscode extension you mentioned
@maskman4821
@maskman4821 11 ай бұрын
Great tutorial 👍
@nk_77777
@nk_77777 10 ай бұрын
Thank you sooooo much!
@meka4996
@meka4996 11 ай бұрын
Regarding the TypeError: Cannot read properties of undefined (reading 'clearStorage') , I solved it after restarting NextJs, waiting for a few seconds, then refreshing the page... then maybe restarting NextJs again...
@connygu
@connygu 11 ай бұрын
thanks @meka4996 for solve this problem! I am not very fit in next.js. But I can remeber, the author Daishi has once written an article about how to use react zustand with nextjs. I will take a look, what he talked about in the article.
@connygu
@connygu Жыл бұрын
The github code for this chapter is here: github.com/niftybytes4u/react_zustand_tutorial/tree/f08aa9f84de08eeec469faeaf128f19a81e3b80a
@amirfarkhadov5926
@amirfarkhadov5926 6 ай бұрын
Amazing! Thanks!
@lazygamer6249
@lazygamer6249 Жыл бұрын
how to save the local storage name dynamically.?
@connygu
@connygu Жыл бұрын
Hi @lazygamer6249 , you can try this code: useFoodStore.persist.setOptions({ name: "your_new_store_name", });
@lazygamer6249
@lazygamer6249 Жыл бұрын
​@@connygu It works . but after reload the original storage key restored. Where can I reach you like discord or any other media.
@connygu
@connygu Жыл бұрын
@@lazygamer6249 Of course it will reload the original key by restart your program. So you task is at the beginning to set a store name check, if the new_store_name existed, then use this one, else set the original store name. // file foodStore.ts const setFoodStoreName = () => { const lastest_store_name = "new_store_name"; // this maybe need a long logic const hasStoreName = Object.keys(localStorage).includes(lastest_store_name); if (hasStoreName) { return lastest_store_name; } else { return "food store"; } }; export const useFoodStore = create()( persist(()=>{...}, { name: setFoodStoreName() } ) ) I think, this should work.
@connygu
@connygu Жыл бұрын
@@lazygamer6249 Currently I don't have a personal discord, but maybe I will set a discord, because I also realized there are more people ask me questions. Maybe a small community will be better. I am not a expert, a small community maybe help each other will be also nice. Thanks for the mention. Currently I think, the best way you reach me is in the youtube comment, I always try my best to answer my video related questions. Otherwise, you can also add my linkedin. :-) www.linkedin.com/in/ying-gu-312b4029/
@lazygamer6249
@lazygamer6249 Жыл бұрын
@@connygu thank you so much for your help and I'm eagerly waiting to join your community.
@jaferhussein2645
@jaferhussein2645 29 күн бұрын
Thanks very much
@FaramarzF.R
@FaramarzF.R 8 ай бұрын
What a unique course. Thank you very much. ❤👏 Is there such a feature in Redux Toolkit to store data in local/session storage? Is there a library that makes it easy to work with Local Sorage when we're not using Zustand?
@kenyie8080
@kenyie8080 11 ай бұрын
Can you show how to persist Maps in localStorage?
@connygu
@connygu 11 ай бұрын
Hi @kenyie8080 , to persist Maps in the localStorage, you just simply reimplement the "getItem", "setItem" and "removeItem" in the "storage" option by yourself. I just made a dogStore example, please see code here: codesandbox.io/s/persist-with-map-c27rc8 The documentation is here: github.com/pmndrs/zustand/blob/main/docs/integrations/persisting-store-data.md#how-do-i-use-it-with-map-and-set
@kenyie8080
@kenyie8080 11 ай бұрын
@@connygu Thank you! I tried by myself before asking you but my localstorage field kept getting cleared on reload. I ended up using an array instead because I didn't figure out how to make a Map work. But I just tried with your code, now it works for me! I must have been doing something wrong before.
@SunithaCK-w5l
@SunithaCK-w5l 7 ай бұрын
Hello, Thanks for this nice tutorial! How can I persist data in cookies using Zustand? Could you show me an example?
@harag9
@harag9 8 ай бұрын
Thanks for this small series of tutorials on Zustand.
@luisjoselopezd
@luisjoselopezd Жыл бұрын
Thank you!
@connygu
@connygu Жыл бұрын
Hi @luisjoselopezd, you are welcome!😊
@meka4996
@meka4996 11 ай бұрын
Resetting the memory also clears my localStorage. I guess "useBearStore.persist.clearStorage" is not needed. Also that gives NextJs problem: TypeError: Cannot read properties of undefined (reading 'clearStorage')
@harag9
@harag9 8 ай бұрын
Correct if you reset the state in memory that will then reset the persist data to the same values. The ClearStorage that was mentioned in the video is basically to just delete the storage.
@promasarachesskit9124
@promasarachesskit9124 5 ай бұрын
Thank you!
@NatalieOndricka
@NatalieOndricka Жыл бұрын
'promo sm'
Знакомство с Zustand - лучшей заменой Redux
29:35
Михаил Непомнящий
Рет қаралды 31 М.
Шок. Никокадо Авокадо похудел на 110 кг
00:44
Spongebob ate Patrick 😱 #meme #spongebob #gmod
00:15
Mr. LoLo
Рет қаралды 17 МЛН
Combining Zustand with React Query
20:24
Cosden Solutions
Рет қаралды 19 М.
Global State Management in NextJs 14 Using Zustand
51:17
Hamed Bahram
Рет қаралды 29 М.
Zustand - Complete Tutorial
19:27
Cosden Solutions
Рет қаралды 89 М.
State Managers Are Making Your Code Worse In React
13:33
Web Dev Simplified
Рет қаралды 186 М.
First Look at Zustand in React: State Management Made Painless!
14:39
Josh tried coding
Рет қаралды 7 М.
Mastering Typescript State using Zustand
13:31
Jack Herrington
Рет қаралды 44 М.
Шок. Никокадо Авокадо похудел на 110 кг
00:44