How to Save React State to Local Storage (with Context API)

Sdílet
Vložit

Komentáře • 15

  • @SILLY_BILLY_777
    @SILLY_BILLY_777 Před 15 dny

    DUDE I'VE BEEN TRYING TO SOLVE THIS PROBLEM FOR LIKE A WEEK THANK YOU SO MUCH

  • @aleksey6151
    @aleksey6151 Před rokem +6

    Very helpful and easy to implement, thanks!

  • @muhammadamjad4046
    @muhammadamjad4046 Před rokem +1

    Very helpful and easy to understand video. Explained nicely what I needed exactly.

  • @tiendung9508
    @tiendung9508 Před rokem +1

    Easy to understand, thank a lot brother ❤

  • @MidhunrajR-im6wu
    @MidhunrajR-im6wu Před 3 měsíci

    Why don't you put more number of videos? Your videos are really useful.

  • @korveld
    @korveld Před měsícem

    Very helpfull tip, thanks!

  • @EzekielOladele-ok2do
    @EzekielOladele-ok2do Před rokem

    Thanks so much. You're a great teacher!!!!

  • @ekinsuaydn7933
    @ekinsuaydn7933 Před rokem

    It's a very helpful video!! Thank you

  • @maskedvillainai
    @maskedvillainai Před 7 měsíci

    AnimatePresence supports calling unmounted prototypes and can be used with any react component. Way easier, one line of code.

  • @shaileeeliyahu9600
    @shaileeeliyahu9600 Před 17 dny

    Thanks for the useful tutorial!
    HOWEVER - Please note that useEffect should NOT be used as a listener, or as a way to activate side-effects (yes, even despite the confusing name).
    This is bad practice because it soon brings to circular/hard-to-manages dependency chains, with no real way to track which change leads to another.
    In this case, you should have wrapped to triggered function - instead of calling the "setTeam" function, you should have called either:
    1.something like "setTeamAndSaveToLocalStorage", which gets a new state value, and sets the local storage to it, and right after that the team state.
    2.a generic "setStateAndSaveToLocalStorage" function, which gets a setState func as a parameter, as well as a key for localStorage, and does the same thing, while just being reusable.
    In general - useEffect should be used as a tap to the mount/willUnmount events of a component. Everything else should be handled by triggers (onClick, onChange, etc...), to avoid listeners which are practically unmaintainable.

  • @bun_bun17
    @bun_bun17 Před 9 měsíci

    you are god sent

  • @gregthomas5887
    @gregthomas5887 Před rokem +2

    Great explanation! Curious: Are there any production-level apps that still make use of localstorage?

    • @nikita-dev
      @nikita-dev  Před rokem

      yes for sure

    • @gregthomas5887
      @gregthomas5887 Před rokem

      @@nikita-dev I've heard from a few other devs that localstorage has a lot of security concerns which is why we rarely see it being used in prod. What kind of services or apps still use it?

  • @vinayakhegde4216
    @vinayakhegde4216 Před rokem

    Hey man i saw your AWS s3 tutorial . I have doubt wether or not i can use multer to upload video files and is their any size limitation if i want to upload video ? My project is smiliar to other ott platforms but mainly it focus on regional and shortflims so is it possible to stream full video's using AWS s3 (with free tier) and also thank you for the formik and module videos i understood those concept well :)