Skip to content

Commit 705e9ff

Browse files
authored
chore(misc): clean up instances of Array.apply (#9798)
* clean up instances of Array.apply * rename item to value
1 parent 42fd765 commit 705e9ff

20 files changed

Lines changed: 33 additions & 33 deletions

packages/react-core/src/components/Nav/examples/NavFlyout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const NavFlyout: React.FunctionComponent = () => {
2222
<MenuItem onClick={onMenuItemClick} flyoutMenu={children} itemId={`nav-flyout-next-menu-${depth}`}>
2323
Next menu
2424
</MenuItem>
25-
{Array.apply(0, Array(numFlyouts - depth)).map((_item, index: number) => (
25+
{Array.from({ length: numFlyouts - depth }).map((_value, index) => (
2626
<MenuItem
2727
onClick={onMenuItemClick}
2828
key={`${depth}-${index}`}

packages/react-core/src/components/Nav/examples/NavHorizontalSubNav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const NavHorizontalSubNav: React.FunctionComponent = () => {
1111
return (
1212
<Nav onSelect={onSelect} variant="horizontal-subnav" aria-label="Horizontal subnav local">
1313
<NavList>
14-
{Array.apply(0, Array(10)).map(function (_item, index: number) {
14+
{Array.from({ length: 10 }).map((_value, index) => {
1515
const num = index + 1;
1616
return (
1717
<NavItem

packages/react-core/src/components/Nav/examples/NavLegacyTertiary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const NavLegacyTertiary: React.FunctionComponent = () => {
1111
return (
1212
<Nav onSelect={onSelect} variant="tertiary" aria-label="Tertiary local">
1313
<NavList>
14-
{Array.apply(0, Array(10)).map(function (_item, index: number) {
14+
{Array.from({ length: 10 }).map(function (_value, index) {
1515
const num = index + 1;
1616
return (
1717
<NavItem

packages/react-core/src/components/Pagination/examples/PaginationSticky.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export const PaginationSticky: React.FunctionComponent = () => {
2727
const buildCards = () => {
2828
const numberOfCards = (page - 1) * perPage + perPage - 1 >= itemCount ? itemCount - (page - 1) * perPage : perPage;
2929

30-
return Array.apply(0, Array(numberOfCards)).map((x, i) => (
31-
<GalleryItem key={i}>
30+
return Array.from({ length: numberOfCards }).map((_value, index) => (
31+
<GalleryItem key={index}>
3232
<Card>
3333
<CardBody>This is a card</CardBody>
3434
</Card>

packages/react-core/src/demos/Banner.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ class BannerDemo extends React.Component {
5858
</PageSection>
5959
<PageSection>
6060
<Gallery hasGutter>
61-
{Array.apply(0, Array(30)).map((x, i) => (
62-
<GalleryItem key={i}>
63-
<Card key={i}>
61+
{Array.from({ length: 30 }).map((_value, index) => (
62+
<GalleryItem key={index}>
63+
<Card key={index}>
6464
<CardBody>This is a card</CardBody>
6565
</Card>
6666
</GalleryItem>
@@ -133,7 +133,7 @@ class BannerDemo extends React.Component {
133133
</PageSection>
134134
<PageSection>
135135
<Gallery hasGutter>
136-
{Array.apply(0, Array(30)).map((x, i) => (
136+
{Array.from({ length: 30 }).map((_value, index) => (
137137
<GalleryItem key={i}>
138138
<Card key={i}>
139139
<CardBody>This is a card</CardBody>

packages/react-core/src/demos/examples/BackToTop/BackToTopNameDemo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ export const Name = () => {
4141
aria-label="Scrollable container of demonstration cards with a back to top element"
4242
>
4343
<Gallery hasGutter>
44-
{Array.apply(0, Array(60)).map((_x: any, i: number) => (
45-
<GalleryItem key={i}>
46-
<Card key={i}>
44+
{Array.from({ length: 60 }).map((_value, index) => (
45+
<GalleryItem key={index}>
46+
<Card key={index}>
4747
<CardBody>
4848
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas fermentum et urna eget semper. Sed
4949
tincidunt purus diam, id sollicitudin est pellentesque eget. Ut eget massa dignissim dolor pretium

packages/react-core/src/demos/examples/Masthead/MastheadWithUtilitiesAndUserDropdownMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,8 @@ export const MastheadWithUtilitiesAndUserDropdownMenu: React.FunctionComponent =
543543
>
544544
<PageSection>
545545
<Gallery hasGutter>
546-
{Array.apply(0, Array(10)).map((x, i) => (
547-
<GalleryItem key={i}>
546+
{Array.from({ length: 10 }).map((_value, index) => (
547+
<GalleryItem key={index}>
548548
<Card>
549549
<CardBody>This is a card</CardBody>
550550
</Card>

packages/react-core/src/demos/examples/Nav/NavDefault.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const NavDefault: React.FunctionComponent = () => {
8383
</PageSection>
8484
<PageSection>
8585
<Gallery hasGutter>
86-
{Array.from({ length: 10 }, (_value: any, index: React.Key) => (
86+
{Array.from({ length: 10 }).map((_value, index) => (
8787
<GalleryItem key={index}>
8888
<Card>
8989
<CardBody>This is a card</CardBody>

packages/react-core/src/demos/examples/Nav/NavExpandable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const NavExpandableDemo: React.FunctionComponent = () => {
109109
</PageSection>
110110
<PageSection>
111111
<Gallery hasGutter>
112-
{Array.from({ length: 10 }, (_value: any, index: React.Key) => (
112+
{Array.from({ length: 10 }).map((_value, index) => (
113113
<GalleryItem key={index}>
114114
<Card>
115115
<CardBody>This is a card</CardBody>

packages/react-core/src/demos/examples/Nav/NavHorizontal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export const NavHorizontal: React.FunctionComponent = () => {
222222
</PageSection>
223223
<PageSection>
224224
<Gallery hasGutter>
225-
{Array.from({ length: 10 }, (_value: any, index: React.Key) => (
225+
{Array.from({ length: 10 }).map((_value, index) => (
226226
<GalleryItem key={index}>
227227
<Card>
228228
<CardBody>This is a card</CardBody>

0 commit comments

Comments
 (0)