Skip to content
Draft
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
2 changes: 1 addition & 1 deletion packages/fastify-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"sanitize-filename": "^1.6.3",
"stream-template": "^0.0.10",
"vite": "^2.9.15",
"wouter": "^2.7.5"
"wouter": "^2.12.1"
},
"peerDependencies": {
"fastify": "^4.24.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/fastify-renderer/src/client/react/matcher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Key, pathToRegexp } from 'path-to-regexp'
import { MatcherFn } from 'wouter'
import type { Match, Path } from 'wouter'

export type MatcherFn = (pattern: Path, path: Path) => Match

/*
* This function specifies how strings like /app/:users/:items* are transformed into regular expressions to pass into path-to-regexp.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'wouter'

declare module 'wouter' {
export interface RouterProps {
export interface RouterObject {
navigationHistory?: NavigationHistory
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,6 @@ export interface ReactRendererOptions {
mode: 'sync' | 'streaming'
}

const staticLocationHook = (path = '/', { record = false } = {}) => {
// eslint-disable-next-line prefer-const
let hook
const navigate = (to, { replace }: { replace?: boolean } = {}) => {
if (record) {
if (replace) {
hook.history.pop()
}
hook.history.push(to)
}
}
hook = () => [path, navigate]
hook.history = [path]
return hook
}

export class ReactRenderer implements Renderer {
static ROUTE_TABLE_ID = '/@fstr!route-table.js'

Expand Down Expand Up @@ -99,7 +83,7 @@ export class ReactRenderer implements Renderer {
Router,
{
base: render.base,
hook: staticLocationHook(destination),
ssrPath: destination,
},
React.createElement(
Layout,
Expand Down
2 changes: 1 addition & 1 deletion packages/test-apps/simple-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"fastify-renderer": "*",
"react": "*",
"react-dom": "*",
"wouter": "^2.7.5",
"wouter": "^2.12.1",
"path-to-regexp": "^6.2.1"
},
"devDependencies": {
Expand Down
Loading
Loading