Is there a way for a child composable to know its ...
# compose
a
Is there a way for a child composable to know its index in a parent? I am aware that there is no built-in way to know this, but wondering if it is somehow possible to achieve this other than asking for the index as a fun param
This is for API design. Such as knowing if a tab is selected within a tab group
d
I had a similar scenario not too long ago where we wanted to scroll to a certain item in a list of settings. From my research I could not find any good way to do this besides representing the entire settings view as a list and find the position of the element I wanted to scroll to that way. 🙃
a
Nope without passing a value down. One might ask “what is a parent?” If the composable is wrapped in multiple layers of parent composables
â˜đŸ» 1
z
You could provide it as a composition local but if you have multiple potential “indexing” parents it could be confusing