-
Notifications
You must be signed in to change notification settings - Fork 232
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
(fix) Fix React missing key warning for QueueTable table filters #1351
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Size Change: +156 B (0%) Total Size: 6.49 MB ℹ️ View Unchanged
|
chibongho
approved these changes
Oct 23, 2024
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.
Thanks for this!
packages/esm-service-queues-app/src/queue-table/default-queue-table.component.tsx
Outdated
Show resolved
Hide resolved
… in QueueTable This PR fixes a missing React key warning for the tableFilter prop in QueueTable. `tableFilter` is an array of React nodes that get rendered as children of the `TableToolbarContent` component. I've renamed the prop to `tableFilters` to better describe that it's an array of filters. Second, I've updated the rendering logic to use the `map` function to iterate over the `tableFilters` array and provide a unique `key` prop to each child. I'm using a `React.Fragment` to wrap each child in the array to avoid unnecessary additional DOM elements. Each of these fragments uses the index of the array as the key. This is not a perfect solution in the sense that keys should be stable and unique identifiers for elements in the array. However, in this case, the array contents are dynamic and may change in size, so a static index identifier works for now. I've also added keys to the `QueueTableByStatusMenu` and `QueueTableMetricsCard` components. I've also fixed the spacing of the filters in the `QueueTable` component as well as removed some unnecessary space from the filter label text.
denniskigen
force-pushed
the
fix/queue-table-key-warning
branch
from
October 23, 2024 18:03
cf67e44
to
88af7f7
Compare
chibongho
approved these changes
Oct 23, 2024
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.
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
Summary
This PR fixes a missing React key warning for the
tableFilter
prop in QueueTable.tableFilter
is an array of React nodes that get rendered as children of theTableToolbarContent
component. I've renamed the prop totableFilters
to better describe that it's an array of filters. Second, I've updated the rendering logic to use themap
function to iterate over thetableFilters
array and provide a uniquekey
prop to each child. I'm using aReact.Fragment
to wrap each child in the array to avoid unnecessary additional DOM elements. Each of these fragments uses the index of the array as the key. This is not a perfect solution in the sense that keys should be stable and unique identifiers for elements in the array. However, in this case, the array contents are dynamic and may change in size, so a static index identifier works for now. I've also added keys to theQueueTableByStatusMenu
andQueueTableMetricsCard
components.I've also fixed the spacing of the filters in the
QueueTable
component as well as removed some unnecessary space from the filter label text.Screenshots
Related Issue
Other