Learn React Error Boundaries In 7 Minutes

  Рет қаралды 128,206

Web Dev Simplified

Web Dev Simplified

Күн бұрын

Пікірлер: 126
@nwaguchima2280
@nwaguchima2280 Жыл бұрын
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.
@mahdiabolghasemi189
@mahdiabolghasemi189 Жыл бұрын
Error Boundary is asked frequently in interviews. Thanks so much!
@AmbroseKTal
@AmbroseKTal Жыл бұрын
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.
@dave6012
@dave6012 Жыл бұрын
Just implemented error boundaries at my job. It was sorely lacking!
@hari9321
@hari9321 Жыл бұрын
We just implemented this past week. Thanks kyle, I am bookmarking this for my team
@MastAdmiLive
@MastAdmiLive Жыл бұрын
Love from India
@arihantjain8347
@arihantjain8347 Жыл бұрын
+1
@ashishkkrishna
@ashishkkrishna Жыл бұрын
-1
@MrTruth-rc2fr
@MrTruth-rc2fr Жыл бұрын
It's 0
@arihantjain8347
@arihantjain8347 Жыл бұрын
@@MrTruth-rc2fr no it isnt including Nilesh (2-1) = +1
@utkarshsiddhpura2401
@utkarshsiddhpura2401 Жыл бұрын
Same to u nilesh bro
@piyushaggarwal5207
@piyushaggarwal5207 Жыл бұрын
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 Жыл бұрын
That seems a better solution, thanks for the tip
@BeeBeeEight
@BeeBeeEight Жыл бұрын
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
@mattb8426
@mattb8426 11 ай бұрын
Just built a new feature and saw this vid, implemented straight away. Very insightful, great video :)
@petarkolev6928
@petarkolev6928 Жыл бұрын
Simple and amazing explanation! Great video!
@FrancescoOrsi
@FrancescoOrsi Жыл бұрын
This component is really really useful.. I will add in my projects ❤
@abdurrahim-bi8kd
@abdurrahim-bi8kd 8 ай бұрын
love it brother. It really help me as a junior developer. Thanks a lot .
@kuken72
@kuken72 Жыл бұрын
TIP: If you wanna catch async errors, you have to put in an event listener for "unhandledrejection" in componentDidMount in your error boundary.
@ahmadshakik
@ahmadshakik Жыл бұрын
yes
@shantanukulkarni007
@shantanukulkarni007 Жыл бұрын
Very nicely explained. Thanks for sharing
@cyril7104
@cyril7104 Жыл бұрын
Most underrated topic and most important! 🎉
@Wakpinside
@Wakpinside Жыл бұрын
Give this man a medal! :D
@guilhermeagostini9247
@guilhermeagostini9247 3 ай бұрын
Really good and straight forward content. Thanks!
@mak271979
@mak271979 Жыл бұрын
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.
@yazraf
@yazraf Жыл бұрын
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 !
@MatthewWeiler1984
@MatthewWeiler1984 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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
@princesiachin279
@princesiachin279 Жыл бұрын
Briliant as always. I've watched your videos since 2019, and it helps me a lot till right now. Big appreciate, Thank you Kyle.
@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
@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.
@alfaphoenix50
@alfaphoenix50 Жыл бұрын
Is there going to be guitar tutorial? april 1st is coming up 😬
@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
@adamreed2000
@adamreed2000 Жыл бұрын
Was just dealing with errors on a project recently, might attempt a refactor.
@theisoj
@theisoj Жыл бұрын
Thanks Kyle! 👍
@jmcclinton8
@jmcclinton8 Жыл бұрын
Nice to see you Kyle.
@edisonbedoyagarcia5416
@edisonbedoyagarcia5416 Жыл бұрын
Thank you for the video, it was amazing
@shilohgeorge1078
@shilohgeorge1078 Жыл бұрын
Thanks a lot, i really appreciate your content
@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?
@vigneshwarrv
@vigneshwarrv Жыл бұрын
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 Жыл бұрын
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 👍
@hmswrth
@hmswrth Жыл бұрын
man, you make things so simple that I actually made a solid career out of your youtube channel.
@majklzumberi1761
@majklzumberi1761 2 ай бұрын
What if you want to "retry loading the failed component", how would you achieve that?
@md.mohiulislam6516
@md.mohiulislam6516 Жыл бұрын
Love from Bangladesh 🇧🇩
@siavashmosadegh1766
@siavashmosadegh1766 Жыл бұрын
thanks man, you were very helpful ;))
@solnone
@solnone Жыл бұрын
Thanks for this tutorial.
@alexanderst.7993
@alexanderst.7993 Жыл бұрын
Is it just me or are you in a really good mood Kyle :D
@IAmLesleh
@IAmLesleh Жыл бұрын
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.
@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?
@jacobsimerly5233
@jacobsimerly5233 Жыл бұрын
How did you tab your down without having to cut and paste it?
@jacobsimerly5233
@jacobsimerly5233 Жыл бұрын
To anyone else curious, it's Alt + Down Arrow
@evolutionxbox
@evolutionxbox 8 ай бұрын
May you share the code for the “getDataFromType” function?
@antu_saha
@antu_saha Жыл бұрын
This is very useful bro
@greengurke
@greengurke Жыл бұрын
How did you move the closing tag at 3:36 down? cool video!
@abdulramonlasisi3385
@abdulramonlasisi3385 Жыл бұрын
I think that's with the "alt + arrow buttons" keys
@anujkumar760
@anujkumar760 8 ай бұрын
nicely explained
@akshaykamble9193
@akshaykamble9193 Жыл бұрын
How to implement error boundary on component in react like remix does?
@User-w8t4t
@User-w8t4t Жыл бұрын
Bro, can I use this component in next js?
@StockWithSayee
@StockWithSayee Жыл бұрын
This can be used for class components but what about functional components
@shatadal_das
@shatadal_das Жыл бұрын
Hey Kyle, Can you please make a video on tests ?
@mauro21523
@mauro21523 Жыл бұрын
The best of bestests 😀
@ajayprakash1167
@ajayprakash1167 Жыл бұрын
Can you provide much more exampl like logging the error
@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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@lemon_maho I was always taught it was best practice but to me without them it makes the code that much more clean
@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 !
@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.
@GachiTscho
@GachiTscho Жыл бұрын
but what about functional component...(i know there is npm lib)
@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.
@Yolo_Swagins
@Yolo_Swagins Жыл бұрын
Thank you
@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 Жыл бұрын
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
@mphy
@mphy Жыл бұрын
very useful
@shiekhpalace2401
@shiekhpalace2401 Жыл бұрын
How do you get known about all these new things
@channel6k
@channel6k Жыл бұрын
Brother can u make video for interview preparation short video for JavaScript 🙏🙏 please
@navaneethbuilds
@navaneethbuilds Жыл бұрын
Can you please start doing tutorials for Vue js 👀
@adityakumarsingh7648
@adityakumarsingh7648 Жыл бұрын
Did same thing but not workig not sure why
@benoitgrasset
@benoitgrasset Жыл бұрын
far better than all these indians tutorials 😂
@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.
@omidsoleimani3817
@omidsoleimani3817 Жыл бұрын
Great content, any plans for a react Formik tutorial?
@ekansh03
@ekansh03 Жыл бұрын
Nice
@investneur8232
@investneur8232 11 ай бұрын
useful
@malachiconstant2756
@malachiconstant2756 Жыл бұрын
What separates a jr dev from a senior dev is how they handle errors… truer words have never been spoken
@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 KZbin and most people don't know how to take udemy courses in free😎 pls, if u can make such tutorials make them.
@WebDevSimplified
@WebDevSimplified Жыл бұрын
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.
@АлексейСтепанов-к9о
@АлексейСтепанов-к9о Жыл бұрын
Kyle, thank you for your videos. It is a chest with treasure for web technology leaners. From Russia with respect to you!!! 🇷🇺🇷🇺🇷🇺
@thebikashweb
@thebikashweb Жыл бұрын
Good video dude! Nice topic to cover, I think I will also make similar video in my channel.
@markcarringer4567
@markcarringer4567 Жыл бұрын
Sure would be nice to see the source code.
@indigosay
@indigosay Жыл бұрын
I need a code
@EranDromy
@EranDromy Жыл бұрын
Seems like react-error-boundary can work on functional components - not just class components.
@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 ...
@bring_you_up
@bring_you_up Жыл бұрын
Никто не пишет уже на классовых компонентах
@avijitchanda7944
@avijitchanda7944 Жыл бұрын
Please make a complex error boundary
@Almighty_Flat_Earth
@Almighty_Flat_Earth Жыл бұрын
React makes web development unnecessarily complicated.
@gamerversez5372
@gamerversez5372 Жыл бұрын
First Comment
@purplesalad
@purplesalad 2 ай бұрын
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.
@8koi245
@8koi245 Жыл бұрын
Next FTW
@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 🤔
@SteveosCPU
@SteveosCPU Жыл бұрын
Wow. I was thinking of using React. Now I know not to. It's CRAP.
@blueprint7000
@blueprint7000 Жыл бұрын
last
@zoranProCode
@zoranProCode Жыл бұрын
Does it catch async errors to?!
@Nicholas-qy5bu
@Nicholas-qy5bu Жыл бұрын
Async error wont crash the UI, they will just terminate the async process. You need to use try catch to catch async error.
How To Debug React Apps Like A Senior Developer
21:07
Web Dev Simplified
Рет қаралды 183 М.
Speed Up Your React Apps With Code Splitting
16:50
Web Dev Simplified
Рет қаралды 395 М.
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 493 М.
This New React Hook Breaks All The Rules And I Love It
7:56
Web Dev Simplified
Рет қаралды 185 М.
Data Fetching using React Suspense and Error Boundary - React Data Fetching Patterns.
34:32
Обработка ошибок в React-приложении | Error Boundary
19:10
Михаил Непомнящий
Рет қаралды 20 М.
Top 6 React Hook Mistakes Beginners Make
21:18
Web Dev Simplified
Рет қаралды 584 М.
Most Beginner React Developers Do This Wrong
13:47
Web Dev Simplified
Рет қаралды 238 М.
I'm Ditching Try/Catch for Good!
10:29
Web Dev Simplified
Рет қаралды 189 М.
ReactJS Tutorial - 32 - Error Boundary
10:53
Codevolution
Рет қаралды 271 М.