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

feat(router): createPages #293

Merged
merged 22 commits into from
Dec 25, 2023
Merged

feat(router): createPages #293

merged 22 commits into from
Dec 25, 2023

Conversation

dai-shi
Copy link
Owner

@dai-shi dai-shi commented Dec 19, 2023

Close #246

Copy link

vercel bot commented Dec 19, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
waku ✅ Ready (Inspect) Visit Preview Dec 25, 2023 0:12am

Copy link

codesandbox-ci bot commented Dec 19, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 72f617d:

Sandbox Source
Vanilla Typescript Configuration
React Configuration
React TypeScript Configuration

@dai-shi dai-shi changed the title feat(router): createPage feat(router): createPages Dec 19, 2023
@Aslemammad
Copy link
Contributor

Why not the traditional file-based routing? Just curious.

@dai-shi
Copy link
Owner Author

dai-shi commented Dec 20, 2023

config-based router matches better for non-node env and for vite/rollup limitation.
We (including third-party library authors) can create a file-based router too.

@himself65
Copy link
Contributor

chunk-43D56K65.js?v=0b716eb3:517 Warning: Expected server HTML to contain a matching <div> in <body>.
    at div
    at Slot (http://localhost:3000/@fs/C:/Users/himse/Code/waku/packages/waku/dist/client.js:85:24)
    at Children (http://localhost:3000/@fs/C:/Users/himse/Code/waku/packages/waku/dist/client.js:98:29)
    at Slot (http://localhost:3000/@fs/C:/Users/himse/Code/waku/packages/waku/dist/client.js:85:24)
    at InnerRouter (http://localhost:3000/@fs/C:/Users/himse/Code/waku/packages/waku/dist/router/client.js:93:24)
    at Root (http://localhost:3000/@fs/C:/Users/himse/Code/waku/packages/waku/dist/client.js:65:24)
    at Router (http://localhost:3000/@fs/C:/Users/himse/Code/waku/packages/waku/dist/router/client.js:187:26)
    at ErrorBoundaryClass (http://localhost:3000/src/components/ErrorBoundary.tsx:4:5)
printWarning @ chunk-43D56K65.js?v=0b716eb3:517
Show 1 more frame
Show less
chunk-43D56K65.js?v=0b716eb3:5811 Uncaught Error: Hydration failed because the initial UI does not match what was rendered on the server.
    at throwOnHydrationMismatch (chunk-43D56K65.js?v=0b716eb3:5811:17)
    at tryToClaimNextHydratableInstance (chunk-43D56K65.js?v=0b716eb3:5847:15)
    at updateHostComponent$1 (chunk-43D56K65.js?v=0b716eb3:12330:13)
    at beginWork$1 (chunk-43D56K65.js?v=0b716eb3:13544:22)
    at HTMLUnknownElement.callCallback2 (chunk-43D56K65.js?v=0b716eb3:14856:22)
    at Object.invokeGuardedCallbackImpl (chunk-43D56K65.js?v=0b716eb3:14881:24)
    at invokeGuardedCallback (chunk-43D56K65.js?v=0b716eb3:14921:37)
    at beginWork (chunk-43D56K65.js?v=0b716eb3:18955:15)
    at performUnitOfWork (chunk-43D56K65.js?v=0b716eb3:18240:20)
    at workLoopSync (chunk-43D56K65.js?v=0b716eb3:18066:13)
chunk-43D56K65.js?v=0b716eb3:517 Warning: An error occurred during hydration. The server HTML was replaced with client content in <body>.
printWarning @ chunk-43D56K65.js?v=0b716eb3:517
Show 1 more frame
Show less
chunk-43D56K65.js?v=0b716eb3:17611 Uncaught Error: Unknown root exit status.
    at finishConcurrentRender (chunk-43D56K65.js?v=0b716eb3:17611:21)
    at performConcurrentWorkOnRoot (chunk-43D56K65.js?v=0b716eb3:17552:17)
    at workLoop (chunk-43D56K65.js?v=0b716eb3:191:42)
    at flushWork (chunk-43D56K65.js?v=0b716eb3:170:22)

@dai-shi
Copy link
Owner Author

dai-shi commented Dec 23, 2023

Thanks.

Why hydration mismatch only on windows...

Copy link
Contributor

@himself65 himself65 left a comment

Choose a reason for hiding this comment

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

Subject: [PATCH] fix: add suspense
---
Index: packages/waku/src/router/client.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/packages/waku/src/router/client.ts b/packages/waku/src/router/client.ts
--- a/packages/waku/src/router/client.ts	(revision 7d50ea37986f14e884897c1af0e156db40bb824d)
+++ b/packages/waku/src/router/client.ts	(date 1703307050084)
@@ -10,6 +10,7 @@
   useState,
   useTransition,
   Fragment,
+  Suspense,
 } from 'react';
 import type { ComponentProps, FunctionComponent, ReactNode } from 'react';
 
@@ -224,13 +225,17 @@
   );
 
   return createElement(
-    Fragment,
-    null,
-    createElement(Slot, { id: SHOULD_SKIP_ID }),
-    createElement(
-      RouterContext.Provider,
-      { value: { loc, changeLocation, prefetchLocation } },
-      children,
+    Suspense,
+    null,
+    createElement(
+      Fragment,
+      null,
+      createElement(Slot, { id: SHOULD_SKIP_ID }),
+      createElement(
+        RouterContext.Provider,
+        { value: { loc, changeLocation, prefetchLocation } },
+        children,
+      ),
     ),
   );
 }

@himself65
Copy link
Contributor

Subject: [PATCH] fix: add suspense
---
Index: packages/waku/src/router/client.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/packages/waku/src/router/client.ts b/packages/waku/src/router/client.ts
--- a/packages/waku/src/router/client.ts	(revision 7d50ea37986f14e884897c1af0e156db40bb824d)
+++ b/packages/waku/src/router/client.ts	(date 1703307050084)
@@ -10,6 +10,7 @@
   useState,
   useTransition,
   Fragment,
+  Suspense,
 } from 'react';
 import type { ComponentProps, FunctionComponent, ReactNode } from 'react';
 
@@ -224,13 +225,17 @@
   );
 
   return createElement(
-    Fragment,
-    null,
-    createElement(Slot, { id: SHOULD_SKIP_ID }),
-    createElement(
-      RouterContext.Provider,
-      { value: { loc, changeLocation, prefetchLocation } },
-      children,
+    Suspense,
+    null,
+    createElement(
+      Fragment,
+      null,
+      createElement(Slot, { id: SHOULD_SKIP_ID }),
+      createElement(
+        RouterContext.Provider,
+        { value: { loc, changeLocation, prefetchLocation } },
+        children,
+      ),
     ),
   );
 }

This will fix, but hydration error still

This reverts commit f32fe55.
@dai-shi
Copy link
Owner Author

dai-shi commented Dec 25, 2023

btw, I don't know how the windows CI failing issue was resolved.

@dai-shi dai-shi merged commit 38405ba into main Dec 25, 2023
27 checks passed
@dai-shi dai-shi deleted the feat/router/create-pages branch December 25, 2023 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

re-design waku/router
3 participants