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

chore(misc): clean up instances of Array.apply #9798

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const NavFlyout: React.FunctionComponent = () => {
<MenuItem onClick={onMenuItemClick} flyoutMenu={children} itemId={`nav-flyout-next-menu-${depth}`}>
Next menu
</MenuItem>
{Array.apply(0, Array(numFlyouts - depth)).map((_item, index: number) => (
{Array.from({ length: numFlyouts - depth }).map((_value, index) => (
<MenuItem
onClick={onMenuItemClick}
key={`${depth}-${index}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const NavHorizontalSubNav: React.FunctionComponent = () => {
return (
<Nav onSelect={onSelect} variant="horizontal-subnav" aria-label="Horizontal subnav local">
<NavList>
{Array.apply(0, Array(10)).map(function (_item, index: number) {
{Array.from({ length: 10 }).map((_value, index) => {
const num = index + 1;
return (
<NavItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const NavLegacyTertiary: React.FunctionComponent = () => {
return (
<Nav onSelect={onSelect} variant="tertiary" aria-label="Tertiary local">
<NavList>
{Array.apply(0, Array(10)).map(function (_item, index: number) {
{Array.from({ length: 10 }).map(function (_value, index) {
const num = index + 1;
return (
<NavItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const PaginationSticky: React.FunctionComponent = () => {
const buildCards = () => {
const numberOfCards = (page - 1) * perPage + perPage - 1 >= itemCount ? itemCount - (page - 1) * perPage : perPage;

return Array.apply(0, Array(numberOfCards)).map((x, i) => (
<GalleryItem key={i}>
return Array.from({ length: numberOfCards }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
</Card>
Expand Down
8 changes: 4 additions & 4 deletions packages/react-core/src/demos/Banner.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class BannerDemo extends React.Component {
</PageSection>
<PageSection>
<Gallery hasGutter>
{Array.apply(0, Array(30)).map((x, i) => (
<GalleryItem key={i}>
<Card key={i}>
{Array.from({ length: 30 }).map((_value, index) => (
<GalleryItem key={index}>
<Card key={index}>
<CardBody>This is a card</CardBody>
</Card>
</GalleryItem>
Expand Down Expand Up @@ -133,7 +133,7 @@ class BannerDemo extends React.Component {
</PageSection>
<PageSection>
<Gallery hasGutter>
{Array.apply(0, Array(30)).map((x, i) => (
{Array.from({ length: 30 }).map((_value, index) => (
<GalleryItem key={i}>
<Card key={i}>
<CardBody>This is a card</CardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export const Name = () => {
aria-label="Scrollable container of demonstration cards with a back to top element"
>
<Gallery hasGutter>
{Array.apply(0, Array(60)).map((_x: any, i: number) => (
<GalleryItem key={i}>
<Card key={i}>
{Array.from({ length: 60 }).map((_value, index) => (
<GalleryItem key={index}>
<Card key={index}>
<CardBody>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas fermentum et urna eget semper. Sed
tincidunt purus diam, id sollicitudin est pellentesque eget. Ut eget massa dignissim dolor pretium
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,8 @@ export const MastheadWithUtilitiesAndUserDropdownMenu: React.FunctionComponent =
>
<PageSection>
<Gallery hasGutter>
{Array.apply(0, Array(10)).map((x, i) => (
<GalleryItem key={i}>
{Array.from({ length: 10 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
</Card>
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core/src/demos/examples/Nav/NavDefault.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const NavDefault: React.FunctionComponent = () => {
</PageSection>
<PageSection>
<Gallery hasGutter>
{Array.from({ length: 10 }, (_value: any, index: React.Key) => (
{Array.from({ length: 10 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const NavExpandableDemo: React.FunctionComponent = () => {
</PageSection>
<PageSection>
<Gallery hasGutter>
{Array.from({ length: 10 }, (_value: any, index: React.Key) => (
{Array.from({ length: 10 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export const NavHorizontal: React.FunctionComponent = () => {
</PageSection>
<PageSection>
<Gallery hasGutter>
{Array.from({ length: 10 }, (_value: any, index: React.Key) => (
{Array.from({ length: 10 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export const NavHorizontalWithSubnav: React.FunctionComponent = () => {
</PageSection>
<PageSection>
<Gallery hasGutter>
{Array.from({ length: 10 }, (_value: any, index: React.Key) => (
{Array.from({ length: 10 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core/src/demos/examples/Nav/NavManual.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const NavManual: React.FunctionComponent = () => {
</PageSection>
<PageSection>
<Gallery hasGutter>
{Array.from({ length: 10 }, (_value: any, index: React.Key) => (
{Array.from({ length: 10 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const NavWithSubnav: React.FunctionComponent = () => {
</PageSection>
<PageSection>
<Gallery hasGutter>
{Array.from({ length: 10 }, (_value: any, index: React.Key) => (
{Array.from({ length: 10 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const NavLight: React.FunctionComponent = () => {
</PageSection>
<PageSection>
<Gallery hasGutter>
{Array.from({ length: 10 }, (_value: any, index: React.Key) => (
{Array.from({ length: 10 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const NavTertiary: React.FunctionComponent = () => {
</PageSection>
<PageSection>
<Gallery hasGutter>
{Array.from({ length: 10 }, (_value: any, index: React.Key) => (
{Array.from({ length: 10 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ export const PageStickySectionBreadcrumb: React.FunctionComponent = () => {
</PageSection>
<PageSection isWidthLimited>
<Gallery hasGutter>
{Array.apply(0, Array(50)).map((_x, i) => (
<GalleryItem key={i}>
{Array.from({ length: 50 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ export const PageStickySectionGroup: React.FunctionComponent = () => {
>
<PageSection>
<Gallery hasGutter>
{Array.apply(0, Array(50)).map((x, i) => (
<GalleryItem key={i}>
{Array.from({ length: 50 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ export const PageStickySectionGroupAlternate: React.FunctionComponent = () => {
</PageGroup>
<PageSection>
<Gallery hasGutter>
{Array.apply(0, Array(50)).map((x, i) => (
<GalleryItem key={i}>
{Array.from({ length: 50 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
</Card>
Expand Down
4 changes: 2 additions & 2 deletions packages/react-core/src/demos/examples/Wizard/InModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const WizardInModalDemo: React.FunctionComponent = () => (
<DashboardWrapper hasPageTemplateTitle>
<PageSection isWidthLimited>
<Gallery hasGutter>
{Array.from({ length: 10 }).map((_, i) => (
<GalleryItem key={i}>
{Array.from({ length: 10 }).map((_value, index) => (
<GalleryItem key={index}>
<Card>
<CardBody>This is a card</CardBody>
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export const BackToTopDemo = () => (
</PageSection>
<PageSection hasOverflowScroll name="scrolling-section">
<Gallery hasGutter>
{Array.apply(0, Array(60)).map((_x: any, i: number) => (
<GalleryItem key={i}>
<Card key={i}>
{Array.from({ length: 60 }).map((_value, index) => (
<GalleryItem key={index}>
<Card key={index}>
<CardBody>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas fermentum et urna eget semper. Sed
tincidunt purus diam, id sollicitudin est pellentesque eget. Ut eget massa dignissim dolor pretium
Expand Down
Loading