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

Components using data-superjson attribute have their DOM unnecessarily recreated #109

Open
1 task done
ericrav opened this issue Sep 13, 2024 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@ericrav
Copy link

ericrav commented Sep 13, 2024

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

When the react server components are refreshed (e.g. via router.refresh()), any component with data-superjson has its DOM tree entirely replaced—this clears things like input state, scroll position, etc and hurts performance.

Here is a minimal reproduction: https://codesandbox.io/p/devbox/fwl4ws?file=/app/page.tsx
Enter values in both textboxes & note when the server refreshes, the normal <input> retains its state, but the <input> inside the data-superjson component is replaced with new dom elements

Expected behavior

The DOM elements should only be unmounted/remounted as normally expected by the rules of React

Reproduction link

https://codesandbox.io/p/devbox/fwl4ws?file=/app/page.tsx

Version

0.6.3

Config

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    swcPlugins: [["next-superjson-plugin", {}]],
  },
};

module.exports = nextConfig;

Additional context

No response

@ericrav ericrav added the bug Something isn't working label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant