I'm using React-Router in my project and I want to redirect to error page like 'Something went wrong' when app crashed.
How can I do that?
Thanks.
CodePudding user response:
Try using useNavigate hook inside catch block
CodePudding user response:
I found a solution after reading react docs. React 16 introduced a new feature called Error Boundries which is like a try/catch blocks. You can learn more in the docs.
This is the link: https://reactjs.org/docs/error-boundaries.html