Skip to content

Commit 5aed18b

Browse files
authored
docs(main): update router doc (#3722)
* docs: update router doc * fix: comments
1 parent 0fc15ca commit 5aed18b

File tree

4 files changed

+255
-115
lines changed

4 files changed

+255
-115
lines changed

packages/document/main-doc/docs/en/apis/app/runtime/router/router.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,28 @@ function App() {
107107
}
108108
```
109109

110+
### useRouteError
111+
112+
```ts
113+
export declare function useRouteError(): unknown;
114+
```
115+
116+
`useRouteError` returns the nearest ancestor Route error。
117+
118+
```tsx
119+
import { useRouteError } from '@modern-js/runtime/router';
120+
const ErrorBoundary = () => {
121+
const error = useRouteError();
122+
return (
123+
<div>
124+
<h1>{error.status}</h1>
125+
<h2>{error.message}</h2>
126+
</div>
127+
);
128+
};
129+
export default ErrorBoundary;
130+
```
131+
110132
## Components
111133

112134
### Link

0 commit comments

Comments
 (0)