Upgrade to Pro — share decks privately, control downloads, hide ads and more …

新しいAPI createRawSnippet触ってみた / What is the crea...

新しいAPI createRawSnippet触ってみた / What is the createRawSnippet?

TOMIKAWA Sotaro

August 30, 2024
Tweet

More Decks by TOMIKAWA Sotaro

Other Decks in Programming

Transcript

  1. createRawSnippet の使い方 {#snippet link(href, content)} <a {href} onfocus={console.log}>{content}</a> {/snippet} const

    link = createRawSnippet((href, content) => ({ render: () => `<a href="${href()}">${content()}</a>`, setup: (a) => { // ↓自分でもろもろ登録する必要がある $effect(() => a.href = href()); $effect(() => a.textContent = content()); a.addEventListener('focus', console.log); return () => a.removeEventListener('focus', console.log); }, }));