Level Up useReducer with Immer

Поделиться
HTML-код
  • Опубликовано: 5 окт 2024

Комментарии • 46

  • @Zombieskelper
    @Zombieskelper 5 лет назад +15

    Thanks for this, i'm managed to rewrite a slightly ratty 388 line state controller for a complex 3 page form into 160 lines that are far easier to read. I see this as an absolute win.

    • @hswolff
      @hswolff  5 лет назад +2

      Yes! That's so great! I agree so much! So glad the video helped.

  • @reaganmatunga3259
    @reaganmatunga3259 2 года назад

    Hey Harry, hook man! 😀😀 Ever since I started following your channel, I've been having fun with React hooks, you had me hooked 😀😀😀

  • @CEFPRAVEENS
    @CEFPRAVEENS 3 года назад

    I hav been watching your videos nowadays ... You taught topics with the daily day usecases .thats why You are so specific than others.

  • @focusiam2027
    @focusiam2027 Год назад

    Thank you! Nice tutorial, very informative 👏👏👏

  • @YeWison
    @YeWison 5 лет назад +4

    Your video always productive, straight ahead and efficient, I'm your fans right now after finishing a few of your React related videos :)

    • @hswolff
      @hswolff  5 лет назад +1

      So glad to hear! Happy to have you around!

  • @michaelprenez-isbell8672
    @michaelprenez-isbell8672 2 года назад

    Another great video, Harry. Makes you realize reducers aren't magic--that how to write the reducer depends on (lower case) context. Excellent work.

  • @Pareshbpatel
    @Pareshbpatel 2 года назад

    A great video on how to use immer with useReducer. Thanks, Harry
    {2021-10-29}

  • @mvgiacomello
    @mvgiacomello 3 года назад

    I like the way you explain things. :)

  • @thereidunmarie
    @thereidunmarie 4 года назад +1

    This was really good explained! Thank you very much!

  • @rahulbera454
    @rahulbera454 3 года назад

    Thanks a lot. I refactored my code and it looks way more readable

  • @Chr1sDrumm3r
    @Chr1sDrumm3r 4 года назад

    Wow! Makes my life so much easier and cleaner with managing my state. This is what I've needed!! Can't wait to check out the next video in the series!

  • @AbhishekKumar-mq1tt
    @AbhishekKumar-mq1tt 5 лет назад +3

    Thank for this awesome video

    • @hswolff
      @hswolff  5 лет назад

      Thank you for watching!

  • @kumarvishalben
    @kumarvishalben 3 года назад

    This is AWESOME

  • @kenneth973
    @kenneth973 4 года назад

    Your channel is GOLDEN

    • @hswolff
      @hswolff  4 года назад

      Hahaha thank you!!

  • @juliohintze595
    @juliohintze595 4 года назад

    I can see this being very useful with a state with nested objects.

  • @bonaoenchelcha
    @bonaoenchelcha 3 года назад

    Wow-what an explanation!

  • @dogaoet
    @dogaoet 3 года назад

    thanks from Brazil.

  • @ElectrOisPower
    @ElectrOisPower 5 лет назад

    Your videos are really appreciated, thanks! keep it up

    • @hswolff
      @hswolff  5 лет назад

      Love it! Thank you!

  • @juhandvan
    @juhandvan 4 года назад

    thanks bro. I really love this tutorial

  • @mohammaddarbandi6285
    @mohammaddarbandi6285 3 года назад

    Thank you very much - it was great 😍✔😘

  • @rafa_hd
    @rafa_hd 5 лет назад +1

    Awesome!!! Thanks man :)

    • @hswolff
      @hswolff  5 лет назад

      You're welcome!

  • @mdjahidulislam9205
    @mdjahidulislam9205 4 года назад

    great video

  • @vrajshah6519
    @vrajshah6519 2 года назад +1

    Does having such mutable state manipulation affect performance? (Increase or Decrease)

  • @alexpro5670
    @alexpro5670 3 года назад

    Cool, man!

  • @mdjahidulislam9205
    @mdjahidulislam9205 4 года назад

    just subscribed

  • @benwozak5296
    @benwozak5296 4 года назад +1

    Can you do this same example with something a little more complex like with axios and an external api or something like that?

    • @hswolff
      @hswolff  4 года назад +1

      What specifically are you curious about?

    • @benwozak5296
      @benwozak5296 4 года назад

      @@hswolff thanks for the reply!
      Maybe something like after logging in, you hit this api:
      randomuser.me/ along with maybe some generic user info, along with a little CRUD?
      I guess I just wanted to see if immer/useReducer combo would be helpful when dealing with larger data sets.

    • @hswolff
      @hswolff  4 года назад

      @@benwozak5296 Yeah it'll definitely scale to a large app. The pitfalls section on immer has a good note too, item #3 immerjs.github.io/immer/docs/pitfalls
      Also I'd try it out and it's always easy to remove immer if you find you need to do your own hand rolled optimized update.

  • @mdjahidulislam9205
    @mdjahidulislam9205 4 года назад

    please make a video how you organize your folder with reducer and context.
    please please please

  • @vincesanchez7790
    @vincesanchez7790 4 года назад

    What if its an array how to mutate it and using the curriedImmer

  • @tiancihe795
    @tiancihe795 5 лет назад +1

    Don't really see the advantage of using immer with useReducer, maybe memory consumption and performance comparison can convince me it is worth the effort and fuss, besides, there is a better solution which is mobx and mobx-react-lite, and honestly, useContext and useReducer is powerfull enough for most scenarios.

    • @hswolff
      @hswolff  5 лет назад

      Immer lets you use the same API as you do with MobX, i.e. directly mutating objects and arrays and not worrying about creating a new instance. Such that if you do use useReducer you can have that flexible API.
      If you go to my blog post hswolff.com/blog/level-up-usereducer-with-immer/#use-immer-with-usereducer you can see an example where Immer makes it much easier to update your state.

    • @BobbyBundlez
      @BobbyBundlez 2 года назад

      yeah i think immer's functionality/purpose is mainly to make state mutation easier. deep level objects can be tricky to not mutate when working with redux or useReducer hooks.... :)

  • @aminshoman1
    @aminshoman1 4 года назад

    not a single dislike :)

    • @hswolff
      @hswolff  4 года назад

      Hahaha! Hopefully that doesn't change!

    • @aminshoman1
      @aminshoman1 4 года назад

      @@hswolff really you can't dislike masterpiece like this one unless you are a complete sycophantic

  • @rose123998
    @rose123998 4 года назад

    IMO it would be fine to use break instead return in loginReducer . isnt?