Skip to content

Commit 2aa596e

Browse files
committed
Upgrade to newer wouter with simpler ssr support
1 parent b8bc330 commit 2aa596e

File tree

6 files changed

+581
-34
lines changed

6 files changed

+581
-34
lines changed

packages/fastify-renderer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"sanitize-filename": "^1.6.3",
6969
"stream-template": "^0.0.10",
7070
"vite": "^2.9.15",
71-
"wouter": "^2.7.5"
71+
"wouter": "^2.12.1"
7272
},
7373
"peerDependencies": {
7474
"fastify": "^4.24.2",

packages/fastify-renderer/src/client/react/matcher.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Key, pathToRegexp } from 'path-to-regexp'
2-
import { MatcherFn } from 'wouter'
2+
import type { Match, Path } from 'wouter'
3+
4+
export type MatcherFn = (pattern: Path, path: Path) => Match
35

46
/*
57
* This function specifies how strings like /app/:users/:items* are transformed into regular expressions to pass into path-to-regexp.

packages/fastify-renderer/src/client/react/wouter-extension.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'wouter'
22

33
declare module 'wouter' {
4-
export interface RouterProps {
4+
export interface RouterObject {
55
navigationHistory?: NavigationHistory
66
}
77

packages/fastify-renderer/src/node/renderers/react/ReactRenderer.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,6 @@ export interface ReactRendererOptions {
2020
mode: 'sync' | 'streaming'
2121
}
2222

23-
const staticLocationHook = (path = '/', { record = false } = {}) => {
24-
// eslint-disable-next-line prefer-const
25-
let hook
26-
const navigate = (to, { replace }: { replace?: boolean } = {}) => {
27-
if (record) {
28-
if (replace) {
29-
hook.history.pop()
30-
}
31-
hook.history.push(to)
32-
}
33-
}
34-
hook = () => [path, navigate]
35-
hook.history = [path]
36-
return hook
37-
}
38-
3923
export class ReactRenderer implements Renderer {
4024
static ROUTE_TABLE_ID = '/@fstr!route-table.js'
4125

@@ -99,7 +83,7 @@ export class ReactRenderer implements Renderer {
9983
Router,
10084
{
10185
base: render.base,
102-
hook: staticLocationHook(destination),
86+
ssrPath: destination,
10387
},
10488
React.createElement(
10589
Layout,

packages/test-apps/simple-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"fastify-renderer": "*",
1414
"react": "*",
1515
"react-dom": "*",
16-
"wouter": "^2.7.5",
16+
"wouter": "^2.12.1",
1717
"path-to-regexp": "^6.2.1"
1818
},
1919
"devDependencies": {

0 commit comments

Comments
 (0)