blitz-js / blitz-js/next-superjson-plugin

Components using data-superjson attribute have their DOM unnecessarily recreated

Open
#109 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
216
Forks
13
PR merge metrics
No merged PRs in 30d

Description

### Verify Next.js canary release

- [X] 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 `` retains its state, but the `` 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

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

module.exports = nextConfig;
```

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.