-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all features: generate rows in a loader
- Loading branch information
Showing
3 changed files
with
50 additions
and
37 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { faker } from '@faker-js/faker'; | ||
import { createFileRoute } from '@tanstack/react-router'; | ||
|
||
import type { Row } from './AllFeatures.lazy'; | ||
|
||
let rows: readonly Row[] | undefined; | ||
|
||
function createRows(): Row[] { | ||
const rows: Row[] = []; | ||
|
||
for (let i = 0; i < 2000; i++) { | ||
rows.push({ | ||
id: `id_${i}`, | ||
avatar: faker.image.avatar(), | ||
email: faker.internet.email(), | ||
title: faker.person.prefix(), | ||
firstName: faker.person.firstName(), | ||
lastName: faker.person.lastName(), | ||
street: faker.location.street(), | ||
zipCode: faker.location.zipCode(), | ||
date: faker.date.past().toLocaleDateString(), | ||
bs: faker.company.buzzPhrase(), | ||
catchPhrase: faker.company.catchPhrase(), | ||
companyName: faker.company.name(), | ||
words: faker.lorem.words(), | ||
sentence: faker.lorem.sentence() | ||
}); | ||
} | ||
|
||
return rows; | ||
} | ||
|
||
export const Route = createFileRoute('/AllFeatures')({ | ||
loader() { | ||
rows ??= createRows(); | ||
return rows; | ||
} | ||
}); |