Learn React Error Boundaries In 7 Minutes

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

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

  • @nwaguchima2280
    @nwaguchima2280 Год назад +19

    This is lovely, thank you. Although if I am using functional components, I find it weird having to write a class components for error boundaries, and this doesn't catch async or handlers, I kinda think it is better to use the package react-error-boundaries since we can get to use the useErrorBoundary hook and still show our error.

  • @dave6012
    @dave6012 Год назад +18

    Just implemented error boundaries at my job. It was sorely lacking!

  • @mahdiabolghasemi189
    @mahdiabolghasemi189 11 месяцев назад +3

    Error Boundary is asked frequently in interviews. Thanks so much!

  • @piyushaggarwal5207
    @piyushaggarwal5207 Год назад +10

    I had to use Error boundary two days back. I ended up using `react-error-boundary` which was suggested if we did not want to use class based components in Beta React docs

    • @jtaylor8606
      @jtaylor8606 Год назад +1

      That seems a better solution, thanks for the tip

  • @AmbroseKTal
    @AmbroseKTal Год назад +6

    I truly appreciate your lessons. There are several videos that duplicate your content, but the way you present these topics is far superior. Not just your demonstrations, but the way you speak, even the tone of your voice, really helps me to understand. It is a free-flowing delivery that is great to listen to, even as background noise at work.

  • @hari9321
    @hari9321 Год назад +17

    We just implemented this past week. Thanks kyle, I am bookmarking this for my team

  • @MastAdmiLive
    @MastAdmiLive Год назад +51

    Love from India

  • @BeeBeeEight
    @BeeBeeEight Год назад +5

    It's nice to have an error boundary in react. It would be PERFECT if react had implemented a functional ErrorBoundary component. Some react-based frameworks have already implemented their own functional error boundaries so it's really weird that react itself doesn't have one.

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

      Yes, nextjs have inbuilt error and loading for a page. But do they have for a component level? Something like this example?

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

      Something like useErrorBoundary would be nice could be as simple as taking a fallback which takes a component function which will handle the error on mount and show the user some Informations but I don't see a problem adding a one time class component as a wrapper

  • @kuken72
    @kuken72 Год назад +31

    TIP: If you wanna catch async errors, you have to put in an event listener for "unhandledrejection" in componentDidMount in your error boundary.

  • @mattb8426
    @mattb8426 10 месяцев назад

    Just built a new feature and saw this vid, implemented straight away. Very insightful, great video :)

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

    Was just dealing with errors on a project recently, might attempt a refactor.

  • @abdurrahim-bi8kd
    @abdurrahim-bi8kd 7 месяцев назад

    love it brother. It really help me as a junior developer. Thanks a lot .

  • @vigneshwarrv
    @vigneshwarrv Год назад +4

    Do wrapping Error Boundary for an entire app is worth it ?? for an api call that fetches content for one component in app.
    Also we need to keep in mind that components unmount by this approach which means we might loose other active states of that mounted components. I think individual Error Boundaries would give better Experience.
    Great Content sir...

    • @Nicholas-qy5bu
      @Nicholas-qy5bu Год назад +4

      Localized and individual error boundaries are the best for a good UX, but a global Error Boundary can catch error which would not necessary comes from api calls. So it is more like a safety net, so you can report back the error to a reporting system and investigate the problem. A good example would be if you are migrating to typescript or a loosely typed application and investigate 'property of undefined' error which can crash the application.

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

      @@Nicholas-qy5bu 👍

  • @FrancescoOrsi
    @FrancescoOrsi Год назад +1

    This component is really really useful.. I will add in my projects ❤

  • @petarkolev6928
    @petarkolev6928 Год назад +2

    Simple and amazing explanation! Great video!

  • @guilhermeagostini9247
    @guilhermeagostini9247 2 месяца назад

    Really good and straight forward content. Thanks!

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

    A huge hearty thanks for the video... Have been following this channel for quite a while now and you have really made the entire web dev simplified...
    If u don't mind, can u create a tutorial on rxjs and it's operators... I have been trying to use it but am unable to bring out entire potential of that tool. It really goes well with react too. Thks

  • @shantanukulkarni007
    @shantanukulkarni007 Год назад +1

    Very nicely explained. Thanks for sharing

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

    Most underrated topic and most important! 🎉

  • @yazraf
    @yazraf Год назад +6

    Amazing, spot on videos, its not just your programming skills that are amazing but your teaching skills are top notch 😉.

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

    Do a video with best practices on fetching multiple datas for multiples components or join multiples datas on react with stateless components. Thx

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

    Thank you for sharing and explaining it so explicitly !

  • @IAmLesleh
    @IAmLesleh Год назад +4

    Error boundaries will only catch errors during render. It will not catch any other errors, e.g. errors that happen in async code, or errors that happen in event handlers.

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

      I guess it is for the easy use of developers for clients

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

      it will cach all those errors that can crash your application.

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

      @@mubasher0331 nope, async errors won't get caught.

  • @MatthewWeiler1984
    @MatthewWeiler1984 Год назад +1

    Thank you, that's very useful.
    Once an ErrorBoundary detects an error and updates its state to that on { hasError: true }, how can it be reset?
    Scenarios:
    If the error was caused by bad user input and your code allows the user to try again.
    If a sporadic error was thrown and may not occur again so trying to render the component again may be an option.

    • @YasinAkimura
      @YasinAkimura Год назад +1

      Just handle the error on the right place and update some context inside componentDidCatch which will rerender the bad component in it's reset state if you use keys they are pretty handy to let react now that they handle their own state

    • @MatthewWeiler1984
      @MatthewWeiler1984 Год назад +1

      @@YasinAkimura makes sense.
      I've just implemented error boundaries in my React app.

  • @montaser-bugless
    @montaser-bugless Год назад

    Awesome Bro.. I Wait For This Video Couple Of Days

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

    Give this man a medal! :D

  • @mak271979
    @mak271979 Год назад +1

    Hi Kayal, thanks for showing us how to use the React way of handling the error boundaries. Could you also please upload a video showing how to use the node package react-error-boundary. I have been trying to use that following exactly what they say on their documentation, but it is not working for me. I am using the error boundary over a react router. I am using react router 6.

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

    Thank you for the video, it was amazing

  • @anujkumar760
    @anujkumar760 7 месяцев назад

    nicely explained

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

    Thanks a lot, i really appreciate your content

  • @alexanderst.7993
    @alexanderst.7993 Год назад

    Is it just me or are you in a really good mood Kyle :D

  • @theisoj
    @theisoj Год назад +1

    Thanks Kyle! 👍

  • @md.mohiulislam6516
    @md.mohiulislam6516 Год назад

    Love from Bangladesh 🇧🇩

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

    Thanks for this tutorial.

  • @SameerSingh-dn6kd
    @SameerSingh-dn6kd Год назад

    Can you make a video on how to make ripple effect (like Google's) in react, if not a whole dedicated video than please make a short on that !

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

    Hey Kyle,
    Can you please make a video on tests ?

  • @alfaphoenix50
    @alfaphoenix50 Год назад +2

    Is there going to be guitar tutorial? april 1st is coming up 😬

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

    thanks man, you were very helpful ;))

  • @princesiachin279
    @princesiachin279 Год назад +1

    Briliant as always.
    I've watched your videos since 2019, and it helps me a lot till right now.
    Big appreciate, Thank you Kyle.

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

    Thank you so much for the quality and useful content! I have a question, is there any way to catch errors in the build-version of the app? I've been struggling with this task for three days now. The deadline is burning.

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

    Brother can u make video for interview preparation short video for JavaScript 🙏🙏 please

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

    Nice to see you Kyle.

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

    very useful

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

    This is very useful bro

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

    Thank you

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

    Can you please start doing tutorials for Vue js 👀

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

    The best of bestests 😀

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

    Nice

  • @hmswrth
    @hmswrth Год назад +2

    man, you make things so simple that I actually made a solid career out of your youtube channel.

  • @investneur8232
    @investneur8232 10 месяцев назад

    useful

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

    Hey kyle bro ! Why u don't make videos for beginners also? Mostly of that basic thongs which are taught in premium courses. I'm saying this because its very hard to find such things on RUclips and most people don't know how to take udemy courses in free😎 pls, if u can make such tutorials make them.

    • @WebDevSimplified
      @WebDevSimplified  Год назад +2

      I have tons of videos on beginner topics and even have full courses that go from beginner to advanced on many topics (linked in the description of all my videos). You can use the search feature on my channel page or my playlists to find these videos.

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

    Can you provide much more exampl like logging the error

  • @renatobmps
    @renatobmps 4 месяца назад

    Is it work if my error boundary is a function component with a try catch that try to render the children component and catch renders fallback?

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

    How did you move the closing tag at 3:36 down? cool video!

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

    Great video! A small unrelated question. Is there a syntactical style reason you don't really use semi-colons to end your statements, or just personal preference?

    • @TannerBarcelos
      @TannerBarcelos Год назад +2

      Most likely personal preference. I think he’s said before he doesn’t like them? I might be wrong or thinking about someone else 😂

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

      @@TannerBarcelos he did.

    • @lemon_maho
      @lemon_maho Год назад +1

      It's personal preference, I don't like using them either

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

      @@TannerBarcelos I could honestly see why..it makes every so muddy with a bunch of them all over the place lol

    • @fullViewJay
      @fullViewJay Год назад +1

      @@lemon_maho I was always taught it was best practice but to me without them it makes the code that much more clean

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

    far better than all these indians tutorials 😂

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

    I wonder, can we create Reusable Error Boundary, Suspense, with dynamic lazy loading child in one component so we can reduce the code?

  • @User-w8t4t
    @User-w8t4t Год назад

    Bro, can I use this component in next js?

  • @majklzumberi1761
    @majklzumberi1761 Месяц назад

    What if you want to "retry loading the failed component", how would you achieve that?

  • @evolutionxbox
    @evolutionxbox 7 месяцев назад

    May you share the code for the “getDataFromType” function?

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

    How to implement error boundary on component in react like remix does?

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

    Good video dude! Nice topic to cover, I think I will also make similar video in my channel.

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

    How did you tab your down without having to cut and paste it?

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

    Is it advisable to use ErrorBoundary during the development stage?

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

      I recommend using react query or something that wraps suspense in production,
      Because if I remember correctly suspense is not fully developed to be used as it is during prod.

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

    This can be used for class components but what about functional components

  • @АлексейСтепанов-к9о

    Kyle, thank you for your videos. It is a chest with treasure for web technology leaners. From Russia with respect to you!!! 🇷🇺🇷🇺🇷🇺

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

    Hey Kyle, what if the hasError changes, will the component remain in error state?

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

      i guess u can test that out.

  • @omidsoleimani3817
    @omidsoleimani3817 Год назад +1

    Great content, any plans for a react Formik tutorial?

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

    How do you get known about all these new things

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

    Seems like react-error-boundary can work on functional components - not just class components.

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

    If you have an ErrorBoundry on a parent (entire app) and then another ErrorBoundry on a child, will the child's ErrorBoundry display first and only if there are no ErrorBoundries on a certain child then does it render the parent ErrorBoundry?

    • @abdulramonlasisi3385
      @abdulramonlasisi3385 Год назад +1

      Errors bubble up to the nearest parent error boundary. so it's depends on where the error occurs, if the error occurs at the child, the child error boundary fallback would be shown, but if it was the whole app, then the page error boundary fallback would be shown instead

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

    Sure would be nice to see the source code.

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

    but what about functional component...(i know there is npm lib)

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

    What separates a jr dev from a senior dev is how they handle errors… truer words have never been spoken

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

    Did same thing but not workig not sure why

  • @Photo-Ninja
    @Photo-Ninja Год назад

    Why did you pasted all the data from json file into the html file instead off import entire file to index.js for example and actually use the data you want from the file? In this example you are not using json file at all.

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

    Please make a complex error boundary

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

    First Comment

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

    I need a code

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

    Никто не пишет уже на классовых компонентах

  • @8koi245
    @8koi245 Год назад

    Next FTW

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

    last

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

    React makes web development unnecessarily complicated.

  • @purplesalad
    @purplesalad Месяц назад

    wrapping the entire application in an error boundary does not make any sense. The whole application will grind to a halt if a subcomponent fails - when the user could have continued without it.

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

    I am facing too many issues when I integrate api with fetch in react native , The problem is that i am getting the api response but the hard part is that set the data with useState, useeffect and many logical issues how to fix that ...

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

    Wow. I was thinking of using React. Now I know not to. It's CRAP.

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

    You don’t need to use class components in 2023

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

      Is there another way of implementing an error boundary in the component level 🤔

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

    Does it catch async errors to?!

    • @Nicholas-qy5bu
      @Nicholas-qy5bu Год назад +1

      Async error wont crash the UI, they will just terminate the async process. You need to use try catch to catch async error.