docs: add subtitles to concepts/routes (#554)

This commit is contained in:
ahuigo
2022-07-30 15:05:55 +00:00
committed by GitHub
parent 0595f92ab8
commit 39309e4c22
+6
View File
@@ -20,6 +20,8 @@ determine exactly what should be rendered. By default components receives props
consisting of: the request URL, the matches from the URL pattern match, and any consisting of: the request URL, the matches from the URL pattern match, and any
data passed to the handler's `render` function. data passed to the handler's `render` function.
## Handler route
Let's look at a basic route that returns a plain text string: Let's look at a basic route that returns a plain text string:
```tsx ```tsx
@@ -41,6 +43,8 @@ handler above is called for `GET` requests. If the handler is a function, it is
called for all requests regardless of the method. If an HTTP method does not called for all requests regardless of the method. If an HTTP method does not
have a corresponding handler, a 405 HTTP error is returned. have a corresponding handler, a 405 HTTP error is returned.
## Component route
Now, let's render some HTML using the route component: Now, let's render some HTML using the route component:
```tsx ```tsx
@@ -63,6 +67,8 @@ default handler is used that just renders out the page component if present. You
can also override the default handler though to modify how exactly rendering can also override the default handler though to modify how exactly rendering
should work. should work.
## Mixed handler and component route
In the below example, a custom handler is used to add a custom header to the In the below example, a custom handler is used to add a custom header to the
response after rendering the page component. response after rendering the page component.