adobe / adobe/react-spectrum

Thoughts on Collection API consistency

Open
#6,596 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

### Provide your feedback here.

I'm curious if it might be possible to make some changes to the way RACs that implement the Collection API are structured.

The current pattern for most RACs is to allow for render props children and composability with slots. However, RACs that implement the Collection API, buck this trend. Children functions are item iterators, internal state of the parent component is unavailable (except to `className` and `style`), and they include renderable props for other states, such as `renderEmptyState`

This makes certain aspects of their internal state completely inaccessible unless the parent completely reimplements and controls that state.

### 🔦 Context

One of the easiest ways to gain access to the complete internal state of an RAC (without reimplementing and controlling its state from a parent) is to utilize the render props children and create an inner component that creates a custom rendering based on that state. But this isn't possible with RACs like `ListBox`, `TagList` and others

### 💻 Code Sample

My thinking is something along the lines of:
```

{(item) => {item.name}}
No items

```

```

{(renderProps) => }

```
Where `MyCustomListBoxInner` is likely to reimplement the above `ListBoxItems` & `EmptyState` but may also include some custom logic based on the internal state of the `ListBox`

### Version

1.2.1

### What browsers are you seeing the problem on?

Other

### If other, please specify

Not a browser issue

### What operating system are you using?

Mac & Windows

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.