docs: remove JSX pragma everywhere
This commit is contained in:
committed by
Luca Casonato
parent
6c4f3a36d0
commit
77142fe4a0
@@ -15,8 +15,6 @@ folder. The file must have a default export that is a regular Preact component.
|
|||||||
A props object of type `UnknownPageProps` is passed in as an argument.
|
A props object of type `UnknownPageProps` is passed in as an argument.
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import { UnknownPageProps } from "$fresh/server.ts";
|
import { UnknownPageProps } from "$fresh/server.ts";
|
||||||
|
|
||||||
export default function NotFoundPage({ url }: UnknownPageProps) {
|
export default function NotFoundPage({ url }: UnknownPageProps) {
|
||||||
@@ -32,8 +30,6 @@ example when the route did match, but the requested resource does not exist.
|
|||||||
This can be achieved with `ctx.renderNotFound`.
|
This can be achieved with `ctx.renderNotFound`.
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||||
|
|
||||||
export const handler: Handlers = {
|
export const handler: Handlers = {
|
||||||
@@ -63,8 +59,6 @@ folder. The file must have a default export that is a regular Preact component.
|
|||||||
A props object of type `ErrorPageProps` is passed in as an argument.
|
A props object of type `ErrorPageProps` is passed in as an argument.
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import { ErrorPageProps } from "$fresh/server.ts";
|
import { ErrorPageProps } from "$fresh/server.ts";
|
||||||
|
|
||||||
export default function Error500Page({ error }: ErrorPageProps) {
|
export default function Error500Page({ error }: ErrorPageProps) {
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ island. The file must have a default export that is a regular Preact component.
|
|||||||
```tsx
|
```tsx
|
||||||
// islands/MyIsland.tsx
|
// islands/MyIsland.tsx
|
||||||
|
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import { useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
|
|
||||||
export default function MyIsland() {
|
export default function MyIsland() {
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ Now, let's render some HTML using the route component:
|
|||||||
```tsx
|
```tsx
|
||||||
// routes/html.tsx
|
// routes/html.tsx
|
||||||
|
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import { PageProps } from "$fresh/server.ts";
|
import { PageProps } from "$fresh/server.ts";
|
||||||
|
|
||||||
export default function Page(props: PageProps) {
|
export default function Page(props: PageProps) {
|
||||||
@@ -75,8 +73,6 @@ response after rendering the page component.
|
|||||||
```tsx
|
```tsx
|
||||||
// routes/html.tsx
|
// routes/html.tsx
|
||||||
|
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import { HandlerContext, Handlers, PageProps } from "$fresh/server.ts";
|
import { HandlerContext, Handlers, PageProps } from "$fresh/server.ts";
|
||||||
|
|
||||||
export const handler: Handlers = {
|
export const handler: Handlers = {
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ is requested at this "locked" path, it will be served with a cache lifetime of
|
|||||||
one year.
|
one year.
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import { asset } from "$fresh/runtime.ts";
|
import { asset } from "$fresh/runtime.ts";
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ Here is an example of an island component that counts down to a specific time.
|
|||||||
```tsx
|
```tsx
|
||||||
// islands/Countdown.tsx
|
// islands/Countdown.tsx
|
||||||
|
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import { useEffect, useState } from "preact/hooks";
|
import { useEffect, useState } from "preact/hooks";
|
||||||
|
|
||||||
const timeFmt = new Intl.RelativeTimeFormat("en-US");
|
const timeFmt = new Intl.RelativeTimeFormat("en-US");
|
||||||
@@ -76,8 +74,6 @@ client with the correct props:
|
|||||||
```tsx
|
```tsx
|
||||||
// routes/countdown.tsx
|
// routes/countdown.tsx
|
||||||
|
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import Countdown from "../islands/Countdown.tsx";
|
import Countdown from "../islands/Countdown.tsx";
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
|
|||||||
@@ -37,9 +37,6 @@ This is done with JSX.
|
|||||||
```tsx
|
```tsx
|
||||||
// routes/about.tsx
|
// routes/about.tsx
|
||||||
|
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
|
|
||||||
export default function AboutPage() {
|
export default function AboutPage() {
|
||||||
return (
|
return (
|
||||||
<main>
|
<main>
|
||||||
@@ -50,10 +47,6 @@ export default function AboutPage() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
> ℹ️ The first two lines are the JSX pragma, and the import for the JSX create
|
|
||||||
> element function. These are just boilerplate. You don't need to know exactly
|
|
||||||
> what they do - they just ensure that JSX gets rendered correctly.
|
|
||||||
|
|
||||||
The new page will be visible at `http://localhost:8000/about`.
|
The new page will be visible at `http://localhost:8000/about`.
|
||||||
|
|
||||||
<!-- You can find more in depth information about routes on the
|
<!-- You can find more in depth information about routes on the
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ then adds a custom header to the response before returning it:
|
|||||||
```tsx
|
```tsx
|
||||||
// routes/about.tsx
|
// routes/about.tsx
|
||||||
|
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import { Handlers } from "$fresh/server.ts";
|
import { Handlers } from "$fresh/server.ts";
|
||||||
|
|
||||||
export const handler: Handlers = {
|
export const handler: Handlers = {
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ as arguments in its `props` object though.
|
|||||||
```tsx
|
```tsx
|
||||||
// routes/greet/[name].tsx
|
// routes/greet/[name].tsx
|
||||||
|
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import { PageProps } from "$fresh/server.ts";
|
import { PageProps } from "$fresh/server.ts";
|
||||||
|
|
||||||
export default function GreetPage(props: PageProps) {
|
export default function GreetPage(props: PageProps) {
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ renders it in a page component.
|
|||||||
```tsx
|
```tsx
|
||||||
// routes/github/[username].tsx
|
// routes/github/[username].tsx
|
||||||
|
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||||
|
|
||||||
interface User {
|
interface User {
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ server side:
|
|||||||
```tsx
|
```tsx
|
||||||
// routes/search.tsx
|
// routes/search.tsx
|
||||||
|
|
||||||
/** @jsx h */
|
|
||||||
import { h } from "preact";
|
|
||||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||||
|
|
||||||
const NAMES = ["Alice", "Bob", "Charlie", "Dave", "Eve", "Frank"];
|
const NAMES = ["Alice", "Bob", "Charlie", "Dave", "Eve", "Frank"];
|
||||||
|
|||||||
Reference in New Issue
Block a user