Scopes Edit on GitHub
In the following tree, ComponentKit has no way to distinguish the three ListItems:
We want a way to give each child a unique identifier:
Scopes give components a persistent, unique identity. They’re needed in three cases:
- Components that have state must have a scope.
- Components that have a controller must have a scope.
- Components that have child components with state or controllers may need a scope, even if they don’t have state or controllers.
Defining a Scope
CKComponentScope type to define a component scope at the top of a component’s
If your component doesn’t have a model object with a unique identifier, you can omit that parameter as long as there won’t be multiple siblings of the same type.