-
-
Notifications
You must be signed in to change notification settings - Fork 637
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
67da2a7
commit a9017a9
Showing
313 changed files
with
9,579 additions
and
655 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
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,24 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
<style type="text/tailwindcss"> | ||
html { | ||
color-scheme: light dark; | ||
} | ||
* { | ||
@apply border-gray-200 dark:border-gray-800; | ||
} | ||
body { | ||
@apply bg-gray-50 text-gray-950 dark:bg-gray-900 dark:text-gray-200; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
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,29 @@ | ||
{ | ||
"name": "tanstack-router-e2e-react-basic-file-based", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite --port=3001", | ||
"build": "vite build && tsc --noEmit", | ||
"serve": "vite preview", | ||
"start": "vite", | ||
"test:e2e": "playwright test --project=chromium" | ||
}, | ||
"dependencies": { | ||
"@tanstack/react-router": "workspace:^", | ||
"@tanstack/router-devtools": "workspace:^", | ||
"@tanstack/router-plugin": "workspace:^", | ||
"immer": "^10.1.1", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"redaxios": "^0.5.1", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "^1.47.1", | ||
"@types/react": "^18.2.47", | ||
"@types/react-dom": "^18.2.18", | ||
"@vitejs/plugin-react": "^4.3.1", | ||
"vite": "^5.4.5" | ||
} | ||
} |
File renamed without changes.
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,25 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
import { RouterProvider, createRouter } from '@tanstack/react-router' | ||
import { routeTree } from './routeTree.gen' | ||
|
||
// Set up a Router instance | ||
const router = createRouter({ | ||
routeTree, | ||
defaultPreload: 'intent', | ||
defaultStaleTime: 5000, | ||
}) | ||
|
||
// Register things for typesafety | ||
declare module '@tanstack/react-router' { | ||
interface Register { | ||
router: typeof router | ||
} | ||
} | ||
|
||
const rootElement = document.getElementById('app')! | ||
|
||
if (!rootElement.innerHTML) { | ||
const root = ReactDOM.createRoot(rootElement) | ||
root.render(<RouterProvider router={router} />) | ||
} |
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,32 @@ | ||
import { notFound } from '@tanstack/react-router' | ||
import axios from 'redaxios' | ||
|
||
export type PostType = { | ||
id: string | ||
title: string | ||
body: string | ||
} | ||
|
||
export const fetchPost = async (postId: string) => { | ||
console.info(`Fetching post with id ${postId}...`) | ||
await new Promise((r) => setTimeout(r, 500)) | ||
const post = await axios | ||
.get<PostType>(`https://jsonplaceholder.typicode.com/posts/${postId}`) | ||
.then((r) => r.data) | ||
.catch((err) => { | ||
if (err.status === 404) { | ||
throw notFound() | ||
} | ||
throw err | ||
}) | ||
|
||
return post | ||
} | ||
|
||
export const fetchPosts = async () => { | ||
console.info('Fetching posts...') | ||
await new Promise((r) => setTimeout(r, 500)) | ||
return axios | ||
.get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') | ||
.then((r) => r.data.slice(0, 10)) | ||
} |
Oops, something went wrong.