-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Waku community adapter #848
base: next
Are you sure you want to change the base?
Conversation
@rmarscher is attempting to deploy a commit to the 47ng Team on Vercel. A member of the Team first needs to authorize it. |
Backlink - dai-shi/waku#1123 It works with SSR if the Waku parent component render setting is "dynamic". I want to see what we can do on the server / RSC side of things. I think this is only a client and SSR implementation so far. |
8261402
to
e112093
Compare
Ha. It totally works with RSC! I updated the adapter to support the scroll and shallow options. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
import { useRouter_UNSTABLE as useRouter } from "waku"; | ||
|
||
export function renderURL(base: string, search: URLSearchParams) { | ||
const hashlessBase = base.split("#")[0] ?? ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Based on usage here, the base
parameter would never contain a hash part (it's fed location.origin + location.pathname
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, thanks. I simplified that. Waku's useRouter returns the current path, so I also added using that. We can preserve the hash when it goes through RSC. I updated the adapter to do that. I think including location.origin
isn't necessary so I dropped it.
const searchParams = new URLSearchParams(query); | ||
const updateUrl = (search: URLSearchParams, options: AdapterOptions) => { | ||
const query = renderQueryString(search); | ||
const hash = typeof location !== "undefined" ? location.hash : ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean this can be called on the server somehow?
useQueryState(s) are client-side hooks, that can render on the server in an SSR pass, but the state updater function should only be called client-side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, great. I assumed that was probably case, but the guard seemed to be safe just in case it was somehow run in an environment without a location global. I'll take it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
91909fc
to
acf8a27
Compare
No description provided.