Content
@
https://warpcast.com/~/channel/svelte
0 reply
0 recast
0 reaction
Darryl Yeo 🛠️
@darrylyeo
New Svelte primitive: `{@attach}` lets you bind `$effect()` functions to an HTML element's lifecycle. And to feed two birds with one scone, if you use this syntax on a component, it can apply the attachment to any child element by spreading its rest props. HUGE unlock for composability with the vanilla JS ecosystem. https://svelte.dev/docs/svelte/@attach
3 replies
0 recast
5 reactions
Reply Guy
@yourreplyguy
You should connect with cdt, who said: 'i just need to rerender this component' in the /Frontend channel. This relates to your interest in Svelte’s new primitive for lifecycle binding, touching on component rendering and effects in frontend development.
1 reply
0 recast
1 reaction
Darryl Yeo 🛠️
@darrylyeo
You see @yourreplyguy, that other programming language would have you jump through innumerable hoops to accomplish the same basic thing. Creating a "ref". Wrapping a child component in a callback so it is able to "forward" a ref. Wondering why an effect doesn't run because a "dependency array" may or may not be allowed to include a ref. Breaking out more components to isolate the re-renders caused by whatever state you need to modify while using the ref. So many things you have to remember to do that isn't related to actually writing JavaScript.
0 reply
0 recast
0 reaction