Learn React Error Boundaries In 7 Minutes

Поділитися
Вставка
  • Опубліковано 14 жов 2024

КОМЕНТАРІ • 124

  • @nwaguchima2280
    @nwaguchima2280 Рік тому +18

    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!

  • @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.

  • @mahdiabolghasemi189
    @mahdiabolghasemi189 10 місяців тому +2

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

  • @hari9321
    @hari9321 Рік тому +17

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

  • @nilesh3931
    @nilesh3931 Рік тому +51

    Love from India

  • @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

  • @guilhermeagostini9247
    @guilhermeagostini9247 21 день тому

    Really good and straight forward content. Thanks!

  • @mattb8426
    @mattb8426 8 місяців тому

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

  • @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.

  • @shantanukulkarni007
    @shantanukulkarni007 Рік тому +1

    Very nicely explained. Thanks for sharing

  • @petarkolev6928
    @petarkolev6928 Рік тому +2

    Simple and amazing explanation! Great video!

  • @abdurrahim-bi8kd
    @abdurrahim-bi8kd 6 місяців тому

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

  • @FrancescoOrsi
    @FrancescoOrsi Рік тому +1

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

  • @adamreed2000
    @adamreed2000 Рік тому

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

  • @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

  • @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 👍

  • @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.

  • @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

  • @yazraf
    @yazraf Рік тому +6

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

  • @iakivpekarskyi1631
    @iakivpekarskyi1631 Рік тому

    Thank you for sharing and explaining it so explicitly !

  • @montaser-bugless
    @montaser-bugless Рік тому

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

  • @Wakpinside
    @Wakpinside Рік тому

    Give this man a medal! :D

  • @alfaphoenix50
    @alfaphoenix50 Рік тому +2

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

  • @cyril7104
    @cyril7104 Рік тому

    Most underrated topic and most important! 🎉

  • @md.mohiulislam6516
    @md.mohiulislam6516 Рік тому

    Love from Bangladesh 🇧🇩

  • @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.

  • @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

  • @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.

  • @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.

  • @anujkumar760
    @anujkumar760 5 місяців тому

    nicely explained

  • @shilohgeorge1078
    @shilohgeorge1078 Рік тому

    Thanks a lot, i really appreciate your content

  • @solnone
    @solnone Рік тому

    Thanks for this tutorial.

  • @siavashmosadegh1766
    @siavashmosadegh1766 Рік тому

    thanks man, you were very helpful ;))

  • @antu_saha
    @antu_saha Рік тому

    This is very useful bro

  • @theisoj
    @theisoj Рік тому +1

    Thanks Kyle! 👍

  • @jmcclinton8
    @jmcclinton8 Рік тому

    Nice to see you Kyle.

  • @shatadal_das
    @shatadal_das Рік тому

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

  • @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 !

  • @alexanderst.7993
    @alexanderst.7993 Рік тому

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

  • @hmswrth
    @hmswrth Рік тому +2

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

  • @channel6k
    @channel6k Рік тому

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

  • @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

  • @mphy
    @mphy Рік тому

    very useful

  • @omidsoleimani3817
    @omidsoleimani3817 Рік тому +1

    Great content, any plans for a react Formik tutorial?

  • @navaneethbuilds
    @navaneethbuilds Рік тому

    Can you please start doing tutorials for Vue js 👀

  • @Yolo_Swagins
    @Yolo_Swagins Рік тому

    Thank you

  • @greengurke
    @greengurke Рік тому

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

  • @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?

  • @sayeesreeram
    @sayeesreeram Рік тому

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

  • @mauro21523
    @mauro21523 Рік тому

    The best of bestests 😀

  • @ajayprakash1167
    @ajayprakash1167 Рік тому

    Can you provide much more exampl like logging the error

  • @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.

  • @renatobmps
    @renatobmps 2 місяці тому

    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?

  • @User-w8t4t
    @User-w8t4t Рік тому

    Bro, can I use this component in next js?

  • @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 UA-cam 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.

  • @evolutionxbox
    @evolutionxbox 5 місяців тому

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

  • @ekansh03
    @ekansh03 Рік тому

    Nice

  • @investneur8232
    @investneur8232 8 місяців тому

    useful

  • @jacobsimerly5233
    @jacobsimerly5233 Рік тому

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

  • @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.

  • @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

  • @thebikashweb
    @thebikashweb Рік тому

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

  • @EranDromy
    @EranDromy Рік тому

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

  • @akshaykamble9193
    @akshaykamble9193 Рік тому

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

  • @GachiTscho
    @GachiTscho Рік тому

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

  • @shiekhpalace2401
    @shiekhpalace2401 Рік тому

    How do you get known about all these new things

  • @benoitgrasset
    @benoitgrasset Рік тому

    far better than all these indians tutorials 😂

  • @malachiconstant2756
    @malachiconstant2756 Рік тому

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

  • @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.

  • @markcarringer4567
    @markcarringer4567 Рік тому

    Sure would be nice to see the source code.

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

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

  • @adityakumarsingh7648
    @adityakumarsingh7648 Рік тому

    Did same thing but not workig not sure why

  • @avijitchanda7944
    @avijitchanda7944 Рік тому

    Please make a complex error boundary

  • @NikhilSharma-rz9jy
    @NikhilSharma-rz9jy Рік тому

    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 ...

  • @indigosay
    @indigosay Рік тому

    I need a code

  • @bring_you_up
    @bring_you_up Рік тому

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

  • @Almighty_Flat_Earth
    @Almighty_Flat_Earth Рік тому

    React makes web development unnecessarily complicated.

  • @8koi245
    @8koi245 Рік тому

    Next FTW

  • @gamerversez5372
    @gamerversez5372 Рік тому

    First Comment

  • @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 🤔

  • @blueprint7000
    @blueprint7000 Рік тому

    last

  • @SteveosCPU
    @SteveosCPU Рік тому

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

  • @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.