kliyer
kliyer
TTCTheo's Typesafe Cult
Created by kliyer on 5/10/2023 in #questions
App Router and shallow routing?
Hey, Perhaps I have not fully adjusted my mental model to NextJS 13 App Router but how would I perform shallow routing? A part of my application's state is managed via the URL query params such that users can easily bookmark a page or share the link. Using the page dir, I could just do router.push('...', { shallow: true }), which updated my my frontend but did not hit my backend. How would I achieve this using the app router? I know that my server components do not depend on the query params but I guess NextJS cannot now that, which is why it triggers a full refresh? Also I know that I should wrap my navigation in a startTransition(() => {...}) to keep the client side state. I guess this works but I'm still hitting my backend which is not what I want. Any ideas?
2 replies
TTCTheo's Typesafe Cult
Created by kliyer on 10/27/2022 in #questions
Automatic account linking after credential provider login
1 replies
TTCTheo's Typesafe Cult
Created by kliyer on 10/5/2022 in #questions
Functions type for key of objects with specific key
Hey, are there any typescript wizards here that could help? I've been trying for a while already but don't really get there. I would like to type a function that takes in two arguments: an arbitrary object as the first argument and for the second argument a key of that object but only allow keys with e.g. a number as an associated value. What's the best way to do this? This is what I have so far. I only want to allow valueKeys which have a type number as a value. Thanks!
const BarChart = <
T extends { date: Date },
K1 extends keyof T,
>({
data,
valueKey,
}: {
data: T[]
valueKey: K1
}) => {...}
const BarChart = <
T extends { date: Date },
K1 extends keyof T,
>({
data,
valueKey,
}: {
data: T[]
valueKey: K1
}) => {...}
13 replies