✨❓ Svelte Question Time ❓✨
"You have a Svelte question, I have an answer" 😱😍
What is the relationship between the component and its parent 01:22 There's no one size fit all solution for this. It's better to study the relationship between the components and figure out what's the best way of communication between the components
Example 1 - Passing the function as a props 05:53 Useful when the component can't live without parent, and the parent can't live without the component
Example 2 - Passing the function as listener for component events 07:13 Useful when you the component does not care about the function, whether the function is being passed to the component or not.
Example 3 - Passing the function via context 10:10 Useful when all the children and grandchildren components may or may not call the function. The function allows all children and grandchildren components to update the state / make changes to the common parent component.
📝 Svelte REPL https://svelte.dev/repl/c030a61df3124ecfb35da039a3366f72?version=3.38.2
🎧 Svelte Tutorial for Beginners https://www.youtube.com/playlist?list=PLoKaNN3BjQX3mxDEVG3oGJx2ByXnue_gR 🎧 Svelte Question Time https://www.youtube.com/playlist?list=PLoKaNN3BjQX1I9FmIoCaws4vUaoqezpc1
Related Resources Svelte https://svelte.dev Svelte REPL https://svelte.dev/repl
🥰 Support me https://www.buymeacoffee.com/lihautan
Want to learn more from me? Check out these links:
Twitter: https://twitter.com/lihautan Blog: https://lihautan.com/ Newsletter: https://lihautan.com/newsletter
Thanks for watching 🥰 -- with love, Li Hau