filmov
tv
How to call functions in parent component

Показать описание
✨❓ Svelte Question Time ❓✨
"You have a Svelte question, I have an answer" 😱😍
Introduction 00:00
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.
---
📚 Related Resources
🔗 Want to learn more from me? Check out these links:
#svelte #sveltequestiontime
Thanks for watching 🥰 -- with love, Li Hau
"You have a Svelte question, I have an answer" 😱😍
Introduction 00:00
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.
---
📚 Related Resources
🔗 Want to learn more from me? Check out these links:
#svelte #sveltequestiontime
Thanks for watching 🥰 -- with love, Li Hau
Комментарии