The Difference Between Smart and Dumb Components

preview_player
Показать описание
Dumb Components are presentational and are portable. They can be used anywhere in your application and are highly performant because they won't trigger change detection.

Smart components can contain logic, can trigger change detection, and can manage data and services.

Most applications will have a good combination of both, but focusing on making some of these choices explicit and understanding when and where you are making these choices can help your application scale better.
Рекомендации по теме
Комментарии
Автор

i'm missing answers to questions like WHY do you do that. what benefits does this separation bring for testing, mocking, performance, ...?

AlexSpieslechner
Автор

Thanks great tutorial.
Can I ask to do a video explaining deep the difference between Change Detection types?

matteobarbieri
Автор

don't call components dumb it makes them sad

blvnktek
Автор

I use --c=OnPush when I want to create a presentational component, but I would also like to skip the creation and extension of ngOnInit hook. Can we easily extend the schematic and have a --dumb flag that would encompass both OnPush and the hook?

aram
Автор

I'm new to Angular. Isn't a service supposed to do the job which is 1 file versus 4?
What advantages a smart component has over a service?

rezataba
Автор

if the dumb component needs to be at a child route, how best to set that up, since we do not use router-outlet right? any good examples?

UniNetwork
Автор

Nice tips as always, thank you
just one question
does it affect the performance if we create custom component inside another one inside another one like 3 or 4 times ?
for example let's say we have like facebook status component that has comments components, reactions component and content component and inside content component we have some others components
is it a good way to build an application ? or it's better to reduce the number of components as much as possible ?

software-egineering-be-tounsi