-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f56202
commit b4a0caa
Showing
2 changed files
with
134 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
test-apps/remix-vite/app/routes/_layout.tests.$id.edit.new.$test.$wildcard.test/route.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import type { ActionFunctionArgs } from "@remix-run/node"; | ||
import { json, type LoaderFunctionArgs } from "@remix-run/node"; | ||
import type { MetaFunction } from "@remix-run/node"; | ||
import { Link, useFetcher, useLoaderData, useSubmit } from "@remix-run/react"; | ||
|
||
export const meta: MetaFunction = () => { | ||
return [ | ||
{ title: "New Remix App" }, | ||
{ name: "description", content: "Welcome to Remix!" }, | ||
]; | ||
}; | ||
|
||
export const loader = async ({ request }: LoaderFunctionArgs) => { | ||
await new Promise((resolve) => setTimeout(resolve, 2000)); | ||
return json({ | ||
should: "work", | ||
with: { | ||
nested: { | ||
objects: { | ||
really: { | ||
deep: "inside", | ||
array: [ | ||
"this", | ||
"is", | ||
"a", | ||
"really", | ||
"long", | ||
"array", | ||
"that", | ||
"should", | ||
"be", | ||
"truncated", | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, { headers: { "Set-Cookie": "test=1; Path=/; HttpOnly; Secure", "Cache-Control": "max-age=20"}}); | ||
}; | ||
|
||
export const action = async ({ request }: ActionFunctionArgs) => { | ||
return new Response(JSON.stringify({ test: "died" })); | ||
}; | ||
|
||
export default function IndexRoute() { | ||
const string = useLoaderData<typeof loader>(); | ||
const lFetcher = useFetcher(); | ||
const lFetcher2 = useFetcher(); | ||
const pFetcher = useFetcher(); | ||
const submit = useSubmit(); | ||
const data = new FormData(); | ||
data.append("test", "test"); | ||
return ( | ||
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.8" }}> | ||
<h1>Welcome to Remix 5</h1> | ||
<button | ||
onClick={() => | ||
lFetcher.submit(null, { method: "GET", action: "/tests/3/edit/new" }) | ||
} | ||
> | ||
FETCHER Loader | ||
</button>{" "} | ||
<button | ||
onClick={() => | ||
lFetcher2.submit(null, { method: "GET", action: "/tests/3/edit/new" }) | ||
} | ||
> | ||
FETCHER 2 Loader | ||
</button> | ||
<button | ||
onClick={() => | ||
pFetcher.submit(null, { method: "POST", action: "/tests/3/edit/new" }) | ||
} | ||
> | ||
FETCHER Action | ||
</button> | ||
<button | ||
onClick={() => { | ||
submit(data, { method: "POST", action: "/tests/3/edit/new/5/5" }); | ||
}} | ||
> | ||
SUBMIT Action test | ||
</button> | ||
<button | ||
onClick={() => | ||
submit(data, { method: "PATCH", action: "/tests/3/edit/new" }) | ||
} | ||
> | ||
SUBMIT Action PATCH | ||
</button> | ||
<button | ||
onClick={() => | ||
submit(null, { method: "DELETE", action: "/tests/3/edit/new" }) | ||
} | ||
> | ||
SUBMIT Action DELETE | ||
</button> | ||
<button | ||
onClick={() => | ||
submit(null, { method: "PUT", action: "/tests/3/edit/new" }) | ||
} | ||
> | ||
SUBMIT Action PUT | ||
</button> | ||
<Link to="/login">Login</Link> | ||
<ul> | ||
<li> | ||
<a | ||
target="_blank" | ||
href="https://remix.run/tutorials/blog" | ||
rel="noreferrer" | ||
> | ||
15m Quickstart Blog Tutorial | ||
</a> | ||
</li> | ||
<li> | ||
<a | ||
target="_blank" | ||
href="https://remix.run/tutorials/jokes" | ||
rel="noreferrer" | ||
> | ||
Deep Dive Jokes App Tutorial | ||
</a> | ||
</li> | ||
<li> | ||
<a target="_blank" href="https://remix.run/docs" rel="noreferrer"> | ||
Remix Docs | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
); | ||
} |