-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Dataviews: Ensure items and fields are using a unique id #56366
Dataviews: Ensure items and fields are using a unique id #56366
Conversation
Size Change: +49 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
@@ -5,6 +5,7 @@ This file documents the DataViews UI component, which provides an API to render | |||
```js | |||
<DataViews | |||
data={ pages } | |||
getItemId={ ( item ) => item.id } |
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.
I'm hesitant to make this a separate prop or a special field but this works for me. We can see over time.
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.
Also, should we document the prop?
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.
Let's do the documentation in a follow up and add more info on the other props too.
Flaky tests detected in 7dda6db. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6942272625
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
What?
This PR adds an
getItemId
prop to DataViews component to ensure we're using unique ids and notindexes
as keys, to avoid rerendering when it's possible.Right now the data we're rendering are not expensive, but this will help in the long run, when we have such, like previews etc..
If
getItemId
is not provided, it fallbacks to indexes as it's on trunk right now.Testing instructions