ReactJS Tutorial - 32 - Error Boundary

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

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

  • @toannew
    @toannew 3 года назад +8

    4:00 code for boundary error
    6:45 why the error boundary important?
    9:18: catthe the error of an eventhandler
    10:45 summary

  • @thebuildguy7
    @thebuildguy7 4 года назад +16

    A really clear and concise explanation of the subject!

  • @adnantariq3346
    @adnantariq3346 3 года назад +6

    Beautiful, just beautiful. My tip my hat to you. You’re young, and your brilliant. I’ve learnt a lot from you, and I hope you go places. Regards

  • @x..darkfate..x
    @x..darkfate..x 4 месяца назад

    You Explain this topic in a very clear and easy manner

  • @Vahidaam
    @Vahidaam 3 года назад +4

    Simple explanation always better to understand the basic concept of some advanced features like this and you did it great. Thank you so much :)

  • @abdous-i8s
    @abdous-i8s 4 года назад +8

    thanks for explaining that in dev mode, the error will still be shown. this really got me stuck

  • @SereneBibleScriptures
    @SereneBibleScriptures 3 года назад +3

    this is beyond decent understanding. thanks!

  • @Heithwald
    @Heithwald 3 года назад +4

    at about 7:00 + you were tallking about: "what if there were thousands of items on an E-Com website". I guess, it is a good idea to pass an array to a HOC, which will wrap each item with an Error Boundary. just came to my mind

  • @AAKSHAS
    @AAKSHAS 3 года назад +2

    9:55 Summary

  • @pradeepbhattacharya8977
    @pradeepbhattacharya8977 4 года назад +2

    Your way of talking and voice really matches with brackeys

  • @Monique-pe3zf
    @Monique-pe3zf 2 года назад

    I never learned so much like in this videos Thank u

  • @shishirmohire9789
    @shishirmohire9789 4 года назад +2

    Joker is a hero in his own story.

  • @diegounanue
    @diegounanue 4 года назад +14

    In getDerivedDromError you change the state just returning it in an object, don't you have to use setState to change any state, or this is another way to do it?

    • @pawanrk4818
      @pawanrk4818 4 года назад +19

      Just like getDerivedStateFromProps , here too cannot use this.setState inside it as it is a static method. The object that you return sets the state.

    • @bhupeshbhatt4334
      @bhupeshbhatt4334 4 года назад +3

      @@pawanrk4818 Why can't we use this.setState inside static method?

    • @JS-ih2lx
      @JS-ih2lx 4 года назад +11

      @@bhupeshbhatt4334 because static methods do not have access to this keyword.

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

    I understand both, Error Boundary and joker is hero.

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

    Wow...for me mits clear...really amazing..thanks sir love you the tutorails.....

  • @shahar1357
    @shahar1357 5 лет назад +5

    I've noticed that if you change the
    if(this.hasError ){} to if(this.state.hasError){}
    you would be able to see the specific Joker Error along with the other real heroes
    without interfering Batman and Superman's Hero tags or the App page itself
    even when the ErrorBoundary tag is not separated to each Hero tag.
    Any thoughts about this case?

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

    Love your videos, thanks for the time-saving edits!

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

    Thank you very much, very clear and on point.

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

    Great explanation for a very important feature !!!

  • @VishalSharma-rn7mt
    @VishalSharma-rn7mt 3 года назад

    Awesome explanation

  • @marlegagaming1274
    @marlegagaming1274 3 года назад +5

    Batman, Superman and something went wrong 🤣🤣

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

    Great explanation . Thank you!

  • @luanecarolineaquinocavalca1064

    thank you for the explanation 🙏🙏

  • @devdrift2181
    @devdrift2181 2 года назад +13

    In react 17.0.2, error is only showing on console not on the webpage in development mode.

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

    perfect explanation! thank you very much!!

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

    Awesome explaination.

  • @sameerdodai1421
    @sameerdodai1421 4 года назад +2

    What extension you used to write "===" like that in if condition of Hero.js line:4

    • @LeandroLuccerini
      @LeandroLuccerini 4 года назад +2

      Go to "Settings" search for Font and in "Font Ligatures" set "editor.fontLigatures": true

  • @curiously-cinnamon
    @curiously-cinnamon Год назад +1

    I am not getting the errors displayed in the UI like in the video at 2:40, 5:22 and 8:53.
    For me it only shows a white screen, and the only way to see errors is by going to the console. Did anyone else come across this problem? Do you know how to get the error UI to display?

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

    Thank you very much, man!

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

    Useful topic!

  • @ravikamble8142
    @ravikamble8142 3 года назад +2

    how to get === triple equalto sign?

  • @Aditya.Santra
    @Aditya.Santra 3 года назад

    Very Helpful Video

  • @akhil8936
    @akhil8936 4 года назад +2

    great explanation , one thing though how is it possible to update State hasError to true inside getDerivedStateFromError() as we saw in previous video that we should use the setState() method and also this method cannot be used here as it's static, could you please clarify how it works simply by setting the hasError to true. TIA

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

      Same Doubt ??

    • @Balamurugan-qp9rj
      @Balamurugan-qp9rj 2 года назад

      @@parthbhoir3730 In above comments mention the exact answer,already we know getDeriveStateFromProps not able to access this.setState,due to static,so only here directly changed

  • @jayjani740
    @jayjani740 4 года назад +3

    One issue: When to use getDerivedStateFromError() and when to use componentDidCatch() ?

    • @alexanderborisov1828
      @alexanderborisov1828 4 года назад +6

      getDirevedStateFromError is used to render a fallback UI whenever error occurs.
      componentDidCatch is used to log the error information in the console.

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

      @@alexanderborisov1828 Thanks alot man :)

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

    thank you very much, very well explained! you have a new subscriber ;)

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

    Perfectionist 👌

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

    In the ErrorBoundry component how can we directly change the state property hasError without using the setState method?

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

    Joker is a hero though..

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

    Nice and waiting for advanced and react native tut

  • @ranjithnayak4822
    @ranjithnayak4822 11 месяцев назад

    Thanks

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

    I have a question, You said we can only change a state inside the setState method, but here you are changing the state inside the getDerivedStateFromError method why?

  • @gouravjain7059
    @gouravjain7059 6 месяцев назад

    amazing

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

    Great video! thank you

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

    What is the setting that make the application production mode?

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

    When I passed throw new Error('Not a Hero'). The error message is displayed in the console but not in the UI Screen. Can anyone help me in this to solve this issue?

    • @curiously-cinnamon
      @curiously-cinnamon Год назад

      I am facing the same issue. Were you able to figure out why the error doesn't show up in the UI?

  • @mukulvarshney669
    @mukulvarshney669 3 года назад +1

    this entire course need to be updated with latest react 8 things mostly things are in class-based component

    • @mayank_upadhyay_19
      @mayank_upadhyay_19 3 года назад +1

      There is no substitute for error boundaries in functional components, it's only class based

  • @julio5434
    @julio5434 3 года назад +1

    💗💗💗

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

    Why hero component is function component? Why not class component. is there any limitation in error boundary.

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

    What is the vscode shortkey to change to become instantly?

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

      Prettier VSCode Extension

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

    can you provide an example , how can i use error boundaries while using router for routing as it is creating issue for me

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

    What about doing this with functional components?

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

    im getting an API and I got an Error, I can't get a particular image. What I want to do is to not show that image. Is there any way to do that?

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

    can we use just a try catch

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

    can you make it catch warnings too? im getting a warning i really need to debug

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

    How to use the componentDidCatch for error

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

    When you say react shows complete error in development mode, How does React knows a particular website loads from Develop instance or Prod Instance.

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

    i am not sure but inside getDerivedStateFromError() we change the state without this.setSate(). So how it goes as you earlier told that for the state to change we have to use setState method..please help me in explaining this. Thanks

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

      I am confused about the same ! @codevolution Please clarify??

    • @mamtagupta5756
      @mamtagupta5756 5 лет назад +7

      Dinesh Pabbi we can change the state without this.setstate as well, but it won’t re-render the component in the UI. so in this case our requirement is to change the state not to rerender the component. Hope this will help.!!

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

      mamta gupta thank you so much!

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

    Awesome

  • @NevilleEkka
    @NevilleEkka 4 года назад +2

    Ooo Not cool...Joker was MY Hero!

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

    How to use boundaries with react router? Is there any way to avoid all this boilerplate?

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

      even i am looking for this answer , if you have any example please suggest

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

    But the confusion is where to put error boundary, should all components need to be wrapped by error boundary and one other things do we need to write specific error boundary for each components? anybody knows help me ,,,,

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

    what is fallback ui?

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

    why I did not get an error without an error boundery?

  • @abdous-i8s
    @abdous-i8s 4 года назад +1

    Uncaught Invariant Violation: Objects are not valid as a React child
    If you get this error, you probably try to render the error message but you try to render the error object. You need to render error.message.

    • @JS-ih2lx
      @JS-ih2lx 4 года назад

      How exactly are we gonna render error.message?

    • @abdous-i8s
      @abdous-i8s 4 года назад +1

      @@JS-ih2lx error is an object with the property message.
      Do console.log(error.message) then you will see the error

    • @JS-ih2lx
      @JS-ih2lx 4 года назад

      @@abdous-i8s Thanksl! Got you.

  • @Nezuko-ey2du
    @Nezuko-ey2du 2 года назад

    I am getting an error saying you cannot just return {heroName}.....Can anyone help me out?

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

    are you using any extension for react snippets, if yes can you name it

    • @RahulKumar-wu1dv
      @RahulKumar-wu1dv 3 года назад

      ES7 React/Redux/GraphQL/React-Native snippets

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

      @@RahulKumar-wu1dv how that equal he writes I had seen before but forgot now I mean in if else

  • @NavneetTaneja-d1y
    @NavneetTaneja-d1y Год назад

    this error page design not coming

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

    why using class component?

    • @Տ·̇
      @Տ·̇ 5 месяцев назад +1

      Only Class components have error boundaries...

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

    How to support old browser version? Im open in firefox 49 and get error const initialization, but my code works fine on chrome

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

      You should search for Babel + Webpack.

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

      Hello Alc Sandr Reebak

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

    does anyone have this code

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

    Could somone tell me how to make that = sign in 2:07 in between jokerName and 'Joker'

  • @rajeshsangapogu
    @rajeshsangapogu 4 года назад +2

    While(true){
    document.write("awesome tutorial");
    }
    I wanted to print infinite times so

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

    In errorBoundary you have written this .props.children what is children here?

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

    static getDerivedStateFromError() {
    return {
    hasError: true
    }
    }
    why didnt use setState to change hasError value ?

    • @JS-ih2lx
      @JS-ih2lx 4 года назад +3

      because static methods do not have access to this keyword so we simply return the object.

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

    Thank you sir

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

    Awesome explanation.Thank you!

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

    Great explanation . Thank you!