Skip to content

Commit ebfab7d

Browse files
authored
v3 (#58)
1 parent a7f8d66 commit ebfab7d

21 files changed

+5951
-8841
lines changed

ADOPTION.md

Lines changed: 0 additions & 81 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ $ npm install --save @swan-io/chicane
2626
## Links
2727

2828
- 📘 [**Documentation**](https://swan-io.github.io/chicane)
29-
- 📗 [**Usage with other routers**](./ADOPTION.md)
3029
- ⚖️ [**License**](./LICENSE)
3130

3231
## Quickstart

__tests__/hydration.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { render } from "@testing-library/react";
2-
import * as React from "react";
32
import { afterEach, expect, test, vi } from "vitest";
43
import { Link, createRouter } from "../src";
54

__tests__/router.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { act, render } from "@testing-library/react";
2-
import * as React from "react";
2+
import { useRef } from "react";
33
import { beforeEach, expect, test } from "vitest";
44
import { createRouter, pushUnsafe, useFocusReset } from "../src";
55
import { setInitialHasLocationChanged } from "../src/history";
@@ -111,7 +111,7 @@ test("getRoute: should match the correct route for given location", () => {
111111
test("useFocusReset: should focus the correct element", () => {
112112
const App = () => {
113113
const route = useRoute(routesToMatch);
114-
const containerRef = React.useRef(null);
114+
const containerRef = useRef(null);
115115

116116
useFocusReset({ route, containerRef });
117117

__tests__/server.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* @vitest-environment node
33
*/
44

5-
import * as React from "react";
65
import { renderToString } from "react-dom/server";
76
import { expect, test } from "vitest";
8-
import { Link, ServerUrlProvider, createRouter } from "../src";
7+
import { Link, createRouter } from "../src";
8+
import { UrlProvider } from "../src/server";
99

1010
const Router = createRouter({
1111
Home: "/",
@@ -51,29 +51,29 @@ const App = () => {
5151
test("Should render home page correctly", () => {
5252
expect(
5353
renderToString(
54-
<ServerUrlProvider value="/">
54+
<UrlProvider value="/">
5555
<App />
56-
</ServerUrlProvider>,
56+
</UrlProvider>,
5757
),
5858
).toMatchSnapshot();
5959
});
6060

6161
test("Should render users page correctly", () => {
6262
expect(
6363
renderToString(
64-
<ServerUrlProvider value="/users">
64+
<UrlProvider value="/users">
6565
<App />
66-
</ServerUrlProvider>,
66+
</UrlProvider>,
6767
),
6868
).toMatchSnapshot();
6969
});
7070

7171
test("Should render user page correctly", () => {
7272
expect(
7373
renderToString(
74-
<ServerUrlProvider value="/users/123">
74+
<UrlProvider value="/users/123">
7575
<App />
76-
</ServerUrlProvider>,
76+
</UrlProvider>,
7777
),
7878
).toMatchSnapshot();
7979
});

docs/docs/server-side-rendering.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ title: Server-side rendering
33
sidebar_label: Server-side rendering
44
---
55

6-
To render your app server-side, wrap it with `ServerUrlProvider`:
6+
To render your app server-side, wrap it with `UrlProvider`:
77

88
```tsx {1,10-12}
9-
import { ServerUrlProvider } from "@swan-io/chicane";
9+
import { UrlProvider } from "@swan-io/chicane/server";
1010
import express from "express";
1111
import { renderToString } from "react-dom/server";
1212
import { App } from "../client/App";
@@ -15,9 +15,9 @@ const app = express();
1515

1616
app.use("*", (req, res) => {
1717
const html = renderToString(
18-
<ServerUrlProvider value={req.originalUrl}>
18+
<UrlProvider value={req.originalUrl}>
1919
<App />
20-
</ServerUrlProvider>,
20+
</UrlProvider>,
2121
);
2222

2323
//

docs/docusaurus.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const config = {
2424
projectName: "chicane", // Usually your repo name.
2525

2626
onBrokenLinks: "throw",
27-
onBrokenMarkdownLinks: "warn",
2827

2928
// Even if you don't use internationalization, you can use this field to set
3029
// useful metadata like html lang. For example, if your site is Chinese, you
@@ -34,6 +33,12 @@ const config = {
3433
locales: ["en"],
3534
},
3635

36+
markdown: {
37+
hooks: {
38+
onBrokenMarkdownLinks: "warn",
39+
},
40+
},
41+
3742
presets: [
3843
[
3944
"classic",

docs/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
"write-heading-ids": "docusaurus write-heading-ids"
1515
},
1616
"dependencies": {
17-
"@docusaurus/core": "3.4.0",
18-
"@docusaurus/preset-classic": "3.4.0",
19-
"@mdx-js/react": "^3.0.1",
17+
"@docusaurus/core": "3.9.2",
18+
"@docusaurus/preset-classic": "3.9.2",
19+
"@mdx-js/react": "^3.1.1",
2020
"clsx": "^2.1.1",
21-
"prism-react-renderer": "^2.3.1",
22-
"react": "^18.3.1",
23-
"react-dom": "^18.3.1"
21+
"prism-react-renderer": "^2.4.1",
22+
"react": "^19.2.0",
23+
"react-dom": "^19.2.0"
2424
},
2525
"devDependencies": {
26-
"@docusaurus/module-type-aliases": "3.4.0",
27-
"@docusaurus/types": "3.4.0"
26+
"@docusaurus/module-type-aliases": "3.9.2",
27+
"@docusaurus/types": "3.9.2"
2828
},
2929
"browserslist": {
3030
"production": [

0 commit comments

Comments
 (0)