Skip to content
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

Svelte 5 :allow pass snippet to parent with export #10652

Closed
zhihengGet opened this issue Feb 27, 2024 · 3 comments
Closed

Svelte 5 :allow pass snippet to parent with export #10652

zhihengGet opened this issue Feb 27, 2024 · 3 comments

Comments

@zhihengGet
Copy link

zhihengGet commented Feb 27, 2024

Describe the problem

since we allow $derived to be exported i think we can allow snippet to be export too

<script>
	let count = $state(0);

	function increment() {
		count += 1;
	}
	export {T}
</script>

{#snippet T()}
	<span>hi</span>
{/snippet}

Describe the proposed solution

Importance

would make my life easier

@rmunn
Copy link
Contributor

rmunn commented Feb 27, 2024

What's the use case here? What does this allow you to do that's easier than making <span>hi</span> a component?

Simple examples/reproductions are good, but this one might be a little too simple right now, as it's not yet clear why this would be helpful.

@zhihengGet
Copy link
Author

zhihengGet commented Feb 27, 2024

better DX imo

the main reason is we can allow parent component to place the snippet wherever he/she likes which means flexibility and child component can be self-contained with sharing states.

without this, i have to create multiple components, and one global $state that share the state or pass rune around which can be not fun

i.e have a dialog component, and i want to allow user to render the 'x' close button, with snippet, i can create it inside dialog and allow user to place where he pleases, even better since snippet have access to the open $state runes, parent component can just use this 'x' button to control the child ( might be a bad example but i hope u get it)

@dummdidumm
Copy link
Member

Closing as duplicate of #10350

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2024
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

No branches or pull requests

3 participants