Y-jiji
Y-jiji

Reputation: 3

Memorize Svelte Components Across Parents

I'm implementing a view layer for a markdown editor in svelte 5.

I've already created an incremental parser that parses markdown to MDAst.

MDAst parse a markdown source file as a hierarchy of sections.

<section>
  <h1>Some Heading</h1>
  <p>A huge paragraph</p>
  <p>Another huge paragraph</p>
</section>

Therefore, when I insert a header, it will split the current section into two sections. In this case, it seems like svelte will remove some children and re-create these children into the newly created section. These components are sometimes large, and these edits cause can visible stucks in rendering.

<section>
  <h1>Some Heading</h1>
  <p>A huge paragraph</p>
</section>
<section>
  <h1>Another Heading</h1>
  <p>Another huge paragraph</p>
</section>

My question is, if I want to cache these children elements across rendering life cycles, what should I do?

Upvotes: 0

Views: 32

Answers (0)

Related Questions