Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use wouter v3 #297

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/ultra-website/importMap.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"react-dom/client": "https://esm.sh/v122/react-dom@0.0.0-experimental-8951c5fc9-20220915/client",
"ultra/": "https://deno.land/x/ultra@v2.3.8/",
"@tanstack/react-query": "https://esm.sh/v122/@tanstack/react-query@4.1.3?external=react",
"wouter": "https://esm.sh/v122/wouter@2.9.0?external=react",
"wouter/static-location": "https://esm.sh/v122/wouter@2.9.0/static-location?external=react"
"wouter": "https://esm.sh/v122/wouter@3.0.2?external=react",
"wouter/": "https://esm.sh/v122/wouter@3.0.2&external=react/"
}
}
3 changes: 1 addition & 2 deletions examples/ultra-website/server.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createServer } from "ultra/server.ts";
import { Router } from "wouter";
import staticLocationHook from "wouter/static-location";
import App from "./src/app.tsx";

const server = await createServer({
Expand All @@ -13,7 +12,7 @@ server.get("*", async (context) => {
* Render the request
*/
const result = await server.render(
<Router hook={staticLocationHook(new URL(context.req.url).pathname)}>
<Router ssrPath={new URL(context.req.url).pathname}>
<App />
</Router>,
);
Expand Down
2 changes: 1 addition & 1 deletion examples/ultra-website/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function App() {
}, [pathname]);

const top = () => {
window.scroll({
globalThis.scroll({
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deno lint complained on this line

top: 0,
left: 0,
behavior: "smooth",
Expand Down
7 changes: 2 additions & 5 deletions examples/with-wouter/client.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import hydrate from "ultra/hydrate.js";
import { Router } from "wouter";
import App from "./src/app.tsx";
import { SearchParamsProvider } from "./src/context/SearchParams.tsx";

hydrate(
document,
<Router>
<SearchParamsProvider value={new URLSearchParams(window.location.search)}>
<App />
</SearchParamsProvider>
<Router ssrSearch={location.search}>
<App />
</Router>,
);
4 changes: 2 additions & 2 deletions examples/with-wouter/importMap.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"react-dom/server": "https://esm.sh/v122/react-dom@18.2.0/server?dev",
"react-dom/client": "https://esm.sh/v122/react-dom@18.2.0/client?dev",
"ultra/": "https://deno.land/x/ultra@v2.3.8/",
"wouter": "https://esm.sh/v122/wouter@2.10.0?external=react",
"wouter/static-location": "https://esm.sh/v122/wouter@2.10.0/static-location?external=wouter"
"wouter": "https://esm.sh/v122/wouter@3.0.2?external=react",
"wouter/": "https://esm.sh/v122/wouter@3.0.2&external=react/"
}
}
9 changes: 3 additions & 6 deletions examples/with-wouter/server.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { createServer } from "ultra/server.ts";
import { Router } from "wouter";
import staticLocationHook from "wouter/static-location";
import App from "./src/app.tsx";
import { SearchParamsProvider } from "./src/context/SearchParams.tsx";

const server = await createServer({
importMapPath: Deno.env.get("ULTRA_MODE") === "development"
Expand All @@ -16,11 +14,10 @@ server.get("*", async (context) => {
* Render the request
*/
const requestUrl = new URL(context.req.url);

const result = await server.render(
<Router hook={staticLocationHook(requestUrl.pathname)}>
<SearchParamsProvider value={requestUrl.searchParams}>
<App />
</SearchParamsProvider>
<Router ssrPath={requestUrl.pathname} ssrSearch={requestUrl.search}>
<App />
</Router>,
);

Expand Down
11 changes: 4 additions & 7 deletions examples/with-wouter/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Link, Route, Switch } from "wouter";
import { Link, Route, Switch, useSearch } from "wouter";
import HomePage from "./pages/Home.tsx";
import AboutPage from "./pages/About.tsx";
import { useSearchParams } from "./context/SearchParams.tsx";

export default function App() {
const searchParams = useSearchParams();
const search = useSearch();
return (
<html lang="en">
<head>
Expand All @@ -20,17 +19,15 @@ export default function App() {
<Link to="/about?foo=bar">About: Foo Bar</Link>
</nav>
<main>
<div>Search params: {searchParams.toString()}</div>
<div>Search params: {search}</div>
<Switch>
<Route path="/">
<HomePage />
</Route>
<Route path="/about">
<AboutPage />
</Route>
<Route>
404
</Route>
<Route>404</Route>
</Switch>
</main>
</body>
Expand Down
41 changes: 0 additions & 41 deletions examples/with-wouter/src/context/SearchParams.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions importMap.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"react-router-dom/server": "https://esm.sh/v122/react-router-dom@6.3.0/server?external=react",
"preact": "https://esm.sh/v122/preact@10.11.0",
"preact/": "https://esm.sh/v122/preact@10.11.0/",
"wouter": "https://esm.sh/v122/wouter@2.10.0?external=react",
"wouter/static-location": "https://esm.sh/v122/wouter@2.10.0/static-location?external=wouter",
"wouter": "https://esm.sh/v122/wouter@3.0.2?external=react",
"wouter/": "https://esm.sh/v122/wouter@3.0.2&external=react/",
"@tanstack/react-query": "https://esm.sh/v122/@tanstack/react-query@4.13.0?external=react",
"@tanstack/react-query-devtools": "https://esm.sh/v122/@tanstack/react-query-devtools@4.13.0?external=react,@tanstack/react-query&dev",
"@trpc/server": "https://esm.sh/v122/@trpc/server@10.0.0",
Expand Down
6 changes: 2 additions & 4 deletions lib/create/common/content/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { BrowserRouter } from "react-router-dom";
${
p.wouter(`// Wouter
import { Router } from "wouter";
import { SearchParamsProvider } from "${ext("./src/wouter/index", true)}";
`)
}

Expand Down Expand Up @@ -47,14 +46,13 @@ ${
${p.reactRouter("<BrowserRouter>")}
${
p.wouter(`
<Router>
<SearchParamsProvider value={new URLSearchParams(window.location.search)}>
<Router ssrSearch={window.location.search}>
`)
}

<App />

${p.wouter("</SearchParamsProvider></Router>")}
${p.wouter("</Router>")}
${p.reactRouter("</BrowserRouter>")}
${p.reactQuery("</Hydrate></QueryClientProvider>")}
${p.reactHelmetAsync("</HelmetProvider>")}
Expand Down
4 changes: 2 additions & 2 deletions lib/create/common/content/importMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export function importMapContent(config: Config) {
}

${
p.wouter('"wouter": "https://esm.sh/wouter@2.9.2?external=react",')
p.wouter('"wouter": "https://esm.sh/v122/wouter@3.0.2?external=react",')
}
${
p.wouter(
'"wouter/static-location": "https://esm.sh/wouter@2.9.2/static-location?external=react",',
'"wouter/": "https://esm.sh/v122/wouter@3.0.2&external=react/",',
)
}

Expand Down
7 changes: 2 additions & 5 deletions lib/create/common/content/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import { StaticRouter } from "react-router-dom/server";
${
p.wouter(`// Wouter
import { Router } from "wouter";
import staticLocationHook from "wouter/static-location";
import { SearchParamsProvider } from "${ext("./src/wouter/index", true)}";
`)
}

Expand Down Expand Up @@ -111,14 +109,13 @@ ${
${p.reactRouter("<StaticRouter location={new URL(context.req.url).pathname}>")}
${
p.wouter(`
<Router hook={staticLocationHook(requestUrl.pathname)}>
<SearchParamsProvider value={requestUrl.searchParams}>
<Router ssrPath={requestUrl.pathname} ssrSearch={requestUrl.search}>
`)
}

<App />

${p.wouter("</SearchParamsProvider></Router>")}
${p.wouter("</Router>")}
${p.reactRouter("</StaticRouter>")}
${p.reactQuery("</QueryClientProvider>")}
${p.reactHelmetAsync("</HelmetProvider>")}
Expand Down
5 changes: 0 additions & 5 deletions lib/create/common/createUltraApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
stitchesConfigContent,
stitchesProviderContent,
} from "../modules/stitches.ts";
import { wouterContent } from "../modules/wouter.ts";
import {
queryClientContent,
useDehydrateReactQueryContent,
Expand Down Expand Up @@ -72,10 +71,6 @@ export async function createUltraApp(config: Config) {
);
}

if (config.includes.includes("wouter")) {
await create(ext("src/wouter/index", true), wouterContent(config));
}

if (config.includes.includes("react-query" || "trpc")) {
await create(
ext("src/react-query/query-client", false),
Expand Down
60 changes: 0 additions & 60 deletions lib/create/modules/wouter.ts

This file was deleted.