Skip to content
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

Add keys when rendering lists #74

Merged
merged 5 commits into from
Oct 27, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions blocks/query/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
TextControl,
} from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { createInterpolateElement, useEffect, useState } from '@wordpress/element';
import {
Fragment,
createInterpolateElement,
useEffect,
useState,
} from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import { addQueryArgs } from '@wordpress/url';

import type { WP_REST_API_Post, WP_REST_API_Posts } from 'wp-types';

Check failure on line 23 in blocks/query/edit.tsx

View workflow job for this annotation

GitHub Actions / node-tests / Install, build, and test

Identifier 'WP_REST_API_Post' is not in camel case

Check failure on line 23 in blocks/query/edit.tsx

View workflow job for this annotation

GitHub Actions / node-tests / Install, build, and test

Identifier 'WP_REST_API_Posts' is not in camel case

import {
mainDedupe,
Expand Down Expand Up @@ -195,8 +200,8 @@
ApiFetch({
path,
}).then((response) => {
const postIds: number[] = (response as WP_REST_API_Posts).map(

Check failure on line 203 in blocks/query/edit.tsx

View workflow job for this annotation

GitHub Actions / node-tests / Install, build, and test

Identifier 'WP_REST_API_Posts' is not in camel case
(post: WP_REST_API_Post) => post.id,

Check failure on line 204 in blocks/query/edit.tsx

View workflow job for this annotation

GitHub Actions / node-tests / Install, build, and test

Identifier 'WP_REST_API_Post' is not in camel case
);
setAttributes({ backfillPosts: postIds });
});
Expand Down Expand Up @@ -262,7 +267,7 @@
manualPosts = manualPosts.slice(0, numberOfPosts); // eslint-disable-line no-param-reassign

// @ts-ignore
const TEMPLATE: Template[] = [

Check failure on line 270 in blocks/query/edit.tsx

View workflow job for this annotation

GitHub Actions / node-tests / Install, build, and test

'Template' is not defined
[
'core/post-template',
{},
Expand Down Expand Up @@ -337,10 +342,11 @@
>
{manualPosts.map((post, index) => (
/* @ts-ignore */
<PanelRow className={classnames(

Check failure on line 345 in blocks/query/edit.tsx

View workflow job for this annotation

GitHub Actions / node-tests / Install, build, and test

Property should be placed on a new line
'manual-posts__container',
{ 'manual-posts__container--selected': manualPosts[index] },
)}
key={index}

Check failure on line 349 in blocks/query/edit.tsx

View workflow job for this annotation

GitHub Actions / node-tests / Install, build, and test

Expected indentation of 14 space characters but found 12

Check failure on line 349 in blocks/query/edit.tsx

View workflow job for this annotation

GitHub Actions / node-tests / Install, build, and test

Do not use Array index in keys
>
<span className="manual-posts__counter">{index + 1}</span>
<PostPicker
Expand All @@ -367,7 +373,7 @@
/>
{Object.keys(availableTaxonomies).length > 0 ? (
allowedTaxonomies.map((taxonomy) => (
<>
<Fragment key={taxonomy}>
{ /* @ts-ignore */ }
<TermSelector
label={availableTaxonomies[taxonomy].name}
renatonascalves marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -376,7 +382,7 @@
onSelect={(newCategories: Term[]) => setTerms(taxonomy, newCategories)}
multiple
/>
</>
</Fragment>
))
) : null}
{ /* @ts-ignore */ }
Expand Down
Loading