Comments (1)
Hi @a-k-kord --
As you noted, custom Link interactivity relies on JavaScript, which means React has to hydrate first. This means that even a regular Link click will trigger an MPA navigation until hydration occurs.
Which means that either making a modal with parallel routing is a bad idea
I'm not sure I necessarily agree with this, since I suspect that being able to click the link and view the final page data is better than clicking the link and nothing happening. But nonetheless, this is still something you can control in your app.
One example of a way to deal with this is to disable SSR on the cards so that it waits for hydration, and specify a Loading
component to use in the meantime. Under the hood, this makes use of React.lazy
and Suspense
to render a fallback UI until hydration. eg:
const LazyCardWithLink = dynamic(() => import("../CardWithLink"), {
ssr: false,
loading() {
const id = React.useContext(CardIdContext);
return (
<Image
width={200}
height={200}
src={`https://picsum.photos/id/${value}/200/300`}
alt="alt"
className="rounded-lg shadow-lg"
priority
/>
);
},
});
This would render the Image
and after hydration, it'll swap to CardWithLink
which is essentially the image wrapped in a Link. But you could also choose to render a more generic fallback instead.
from next.js.
Related Issues (20)
- Next.js v15 (canary) cannot show `Modal` of `@chakra-ui/react` v2.8.2 only on `next dev`
- Redirection (redirect function) does not work in a server action with trycatch HOT 3
- Calling `notFound()` from a dynamic catch-all segment displays unnecessary console warning about missing slots
- <Link> to an AppRoute Page with a <form action={}> renders a form tag with a js error in place of the function name on the action prop.
- revalidatePath doesn't invalidate the edge cache of serverless functions HOT 1
- Webpack Loader set from Webpack Plugin with Next Compiler can't accept value contains `!(exclamation mark)`
- Usage of Recoil in Nextjs app (turborepo) induces a TypeError: Cannot destructure property 'ReactCurrentDispatcher. HOT 5
- Next js build issue, FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
- Partial Prerendering does a full fetch of the whole page on every page view? HOT 2
- The dev container config creates a container with node version 16 which is no longer supported. HOT 1
- When a Server Action that calls `redirect` is composed with an Action on the Client `undefined` is returned to the Client. HOT 4
- NextJs[^14.2.3] build error: Cannot read properties of undefined (reading 'hasOwnProperty') HOT 1
- Turbo: json-schema-to-typescript package errors (Cannot convert undefined or null to object)
- npm run dev never finish to compile HOT 3
- project builds in Vercel but link only populates "Application error: a server-side exception has occurred" and Runlog indicates PrismaClientInitializationError
- Docs: App Router "Adding Authentication" page does not 'use server' in code. HOT 2
- NextURL strips trailing slashes, even when config is set to manual trailing slash handling
- Application Crash when google translated and dropdown is chose. HOT 2
- Page is remounted when params change in (optional) catch all routes
- Middleware URL normalization does not respect `skipTrailingSlashRedirect`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next.js.