Skip to content

$derived causes SSR error when referencing a property with the same name as a nested reactive state #16050

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

Closed
legendSabbir opened this issue May 31, 2025 · 0 comments · Fixed by #16051
Assignees

Comments

@legendSabbir
Copy link

legendSabbir commented May 31, 2025

Describe the bug

When using $derived to reference a nested reactive state (like this.icon.current) and the local property is named the same (current), it causes an error during server-side rendering (SSR). Renaming the local property to something else resolves the issue.

Reproduction

class Hello {
  current = $state([]);
}

class World {
  icon = new Hello();
  
  // Causes SSR error if property name is "current". renaming variable name solves error
  current = $derived({
    icon: this.icon.current,
  });

  constructor() {
    // Triggers the SSR issue
    this.icon.current = ["Hello", "World"];
  }
}

const world = new World();

Logs

//

System Info

//

Severity

annoyance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants