Why React Strict Mode breaks your app - on purpose

Ойын-сауық

Check out my premium video courses on Build UI:
buildui.com

Пікірлер: 29

  • @deiminator2
    @deiminator2 Жыл бұрын

    Bro I'm an experienced react dev so I already know most of the stuff you talk about. But you are probably the best coding KZreadr on the platform, no yelling mild takes, not pushing an agenda, just clean, precise and interesting content. Keep it up!

  • @robbyoconnor

    @robbyoconnor

    Жыл бұрын

    I've met him in person... he's like this in person as well. Very down to earth

  • @samselikoff

    @samselikoff

    Жыл бұрын

    Really appreciate this message 😊 👊

  • @UncleDavid

    @UncleDavid

    Жыл бұрын

    he has baraka in him lol

  • @Developer888

    @Developer888

    Жыл бұрын

    As a react rookie, I appreciate the breakdown

  • @wfl-junior
    @wfl-junior Жыл бұрын

    That probably explains why I get the api calls with react query running twice on mount, good thing I started using the signal to abort the request on cleanup. I was aware of React's strict mode, but never understood it correctly, this video made it very clear, thank you! And I think strict mode is a must, very useful.

  • @StingSting844
    @StingSting844 Жыл бұрын

    bro why are you so good in teaching?! Its abnormal that I'm able to grasp every single word that comes out of your mouth!

  • @codingwithdidem
    @codingwithdidem Жыл бұрын

    Thanks! I often misunderstand the whole concept of strict mode. One time I was fetching the data multiple times and end up wasting 1 day only to find out it was happening bcz of the strict mode tho:)

  • @cdes
    @cdes Жыл бұрын

    I’ve always enjoyed your streams while you’re working on Mirage. When I get a notification for a new video from you, I get really excited, and you never disappoint. Keep on going! Your videos are insanely good. Quality content, superb delivery. Only a if you make them more often.

  • @user-ze5ew6fh2i
    @user-ze5ew6fh2i Жыл бұрын

    The way you talk is really awesome man!! And I never heard about chaos monkey. Thanks

  • @HeyNoah
    @HeyNoah Жыл бұрын

    This is great! Thank you so much for this breakdown! 🙏

  • @simonswiss
    @simonswiss Жыл бұрын

    Sheesh this was really great! I knew about the "cleanup" return function in useEffect, but I have probably done that mistake 100 times in my apps, and never noticed 😅 Also - the backlight doubling as practical light in the background is 🧑‍🍳😘

  • @_va3y
    @_va3y Жыл бұрын

    Your vim chops are smooth.. I’ve also got into it last month

  • @pablozuta2402

    @pablozuta2402

    Жыл бұрын

    That's vscode bro

  • @tefkah

    @tefkah

    Жыл бұрын

    @@pablozuta2402 yeah but he's clearly using vim bindings

  • @samselikoff

    @samselikoff

    Жыл бұрын

    Best investment you’ll ever make!

  • @andrewsidorchuk9289
    @andrewsidorchuk9289 Жыл бұрын

    Awesome explanation! Thanks man

  • @mmmike3426
    @mmmike3426 Жыл бұрын

    The production value of this video is so high. Damn man, even down to that exceptionally groomed beard 😂 You're basically the Wenger of dev content!

  • @kevinbatdorf
    @kevinbatdorf Жыл бұрын

    The proper way to implement this is to instead use setTimeout and add count as a dependency, so that when count is updated it restarts the timeout. setInterval should never be used as it does not guarantee execution if the inner function takes longer than the interval. (there are other issues with setInterval as well - can google it for more info)

  • @kevinbatdorf

    @kevinbatdorf

    Жыл бұрын

    Also, I'm not being critical of your content. I know it wasn't the point of this video. Keep it coming!

  • @samselikoff

    @samselikoff

    Жыл бұрын

    The logic is "increase the count by 1 every second" - that's an interval. You don't want to use count as a dependency to achieve this behavior for two reasons: first, it's literally not a dependency when using the function version of setState, and second (and more importantly), count could change for reasons other than the interval increasing it. (If you wanted different logic based on count changing for other reasons, that would also be achievable, but it's a different requirement.) I'm not sure I understand your point about "the inner function taking longer than the interval". The inner function here is just a call to setState and is not asynchronous code, and it would be the same if it were in a timeout. You can absolutely use setInterval in React applications. There do exist libraries like useInterval which offer more functionality, but they ultimately are more sophisticated wrappers around setInterval. (And no criticism taken, I welcome the questions!)

  • @flying_salt
    @flying_salt8 ай бұрын

    Thanks a lot

  • @ThomazMartinez
    @ThomazMartinez Жыл бұрын

    For me most of the time is i dont get errors with strict mode in dev but when in Prod then i start getting issues

  • @justine_chang39
    @justine_chang39 Жыл бұрын

    React Strict Mode white background blinded me, now I sing about just calling someone and saying I love you.

  • @typescripter
    @typescripter Жыл бұрын

    Thx

  • @pelaoinfo
    @pelaoinfo5 ай бұрын

    this is completely broken when you try to use refs

  • @yairvsync
    @yairvsync11 ай бұрын

    React Strict mode simple replaces a "maybe" bug with a "certain" but which noob/blind devs might miss and therefore introduce bugs into the system. Strict mode is a big no-no for me, for years. It's catastrophic.

  • @clear_out6474
    @clear_out6474 Жыл бұрын

    Why was this in my recommended? lmao im not close to be a programer xD cool explanation tho 👍

Келесі