how to use errorElement #11352
-
I'm following offical tutorial building my react app's routes, but failed to get the same result as doc when using errorElement. I'm using createBrowserRouter. Here is my index.tsx(btw, I'm using ts in my app):
And this is my error-page.tsx:
But I didn't get my custom error page: Although the doc maintainer humbly and humorously saying that the default error page is Gross!~~ I did some digging on my own by Goolge, Stackoverflow, Github Issues and Youtube, and even ChatGPT, but still failed to my expected error page.. I tried to add the catch-all route at the end of the route configuration:
But the browser still gave me this: And there was a suggestion that I should add some logs in my error page component then check the Console in the browser devtool. I did put a row of logging the error from Then I saw a
Still got no luck: I'm start thinking if this related to any project configs or ts syntax/defines..
Maybe someone can tell what's wrong in any of those files.. And I did get my custom error page when I did this in my
I know that I render the error page directly on route And I found that if I just put the
I did exactly the same thing as the offical tutorial(I think so..), but I were seeing totally different result and have no clue.. It really drove me crazy, I'm stucking here.. Somebody has the knowledge and time, help, please.. |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 9 replies
-
can you provide a codesandbox link or stackblitz link? and it's the react router stuff, I suggest you create discuss on react router repo instead remixl |
Beta Was this translation helpful? Give feedback.
-
And I would suggest you follow along with the tutorial. Just create a new project using vite like the tutorial said.
|
Beta Was this translation helpful? Give feedback.
you need to config webpack right. it should be a SPA application if you want to use react-router.