-
Notifications
You must be signed in to change notification settings - Fork 685
Revert List component to old API #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
if (prop != null && !isIterable(prop)) { | ||
return new Error( | ||
`Invalid prop \`${propName}\` supplied to \`${componentName}\`. Validation failed.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this message more specific? Doesn't seem to call out that we're expecting an iterable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DrewML Updated. 👍
Thanks for doing this! Good that it now works seamlessly with our payloads, but can be useable by others with differently-shaped data. |
31b5af6
to
b8481a5
Compare
No problem, it's just a different approach to the same solution. Fixes #41. |
Instead of accepting a Map-compatible iterable for items, accept an Array-compatible iterable and a keymaking function `getItemKey`.
b8481a5
to
6e040ba
Compare
Pull Request Test Coverage Report for Build 132
💛 - Coveralls |
This PR is a:
[ ] New feature
[ ] Enhancement/Optimization
[x] Refactor
[ ] Bugfix
[ ] Test for existing code
[ ] Documentation
Summary
When this pull request is merged, it will...
Change the
List
component's API, such that it only expectsitems
to be an iterable, instead of a stricter,Map
-compatible, two-dimensional iterable. This change will make it more expedient to pass collections of data straight from the API toList
without having to transform them first.Additional information
Since we can't safely mandate that all collections consist of objects with an
id
property,List
must also accept a key-generation function,getItemKey
. This function will default to({ id }) => id
, which plucks theid
prop from a plain object, covering the most common case. For flat collections of strings, such as tags, users can supply an identity function; for more unusual collections where the primary key is something other thanid
, they can supply a custom function.This PR is marked [WIP] until this API change is approved. Once approved, instances of
List
in this repo have to be updated.