Skip to content

Replace internalContent prop sync effects with $derived #693

Description

@malibio

Overview

Replace $effect blocks that sync internalContent from content prop with $derived pattern.

Problem Statement

Four node components use the anti-pattern of syncing a prop to internal state via $effect:

let internalContent = $state(content);
$effect(() => {
  internalContent = content;
});

This is unnecessary state duplication. The internalContent can simply be derived from content.

Files to Modify

  1. calendar.svelte (line 39) - sync external value to internal
  2. code-block-node.svelte (line 76) - sync internalContent
  3. ordered-list-node.svelte (line 54) - sync internalContent
  4. quote-block-node.svelte (line 55) - sync internalContent

Proposed Solution

Replace with $derived:

// BEFORE
let internalContent = $state(content);
$effect(() => {
  internalContent = content;
});

// AFTER
const internalContent = $derived(content);

Or if mutation is needed, use bind:content in parent and remove internal state entirely.

Acceptance Criteria

  • calendar.svelte $effect replaced with $derived
  • code-block-node.svelte $effect replaced with $derived
  • ordered-list-node.svelte $effect replaced with $derived
  • quote-block-node.svelte $effect replaced with $derived
  • 4 $effect blocks eliminated
  • All node types render correctly
  • Edit mode works correctly
  • Tests pass (bun run test:all)
  • Quality checks pass (bun run quality:fix)

Related Issues

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions