mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
* fix(select): `SelectItem` does not accept value props * refactor: do not use the index as `key` * Update .changeset/light-hairs-draw.md * chore: remove unnecessary `value` props * chore: update changeset * refactor: remove unnecessary value prop --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com>
54 lines
1011 B
JavaScript
54 lines
1011 B
JavaScript
import {Select, SelectItem} from "@heroui/react";
|
|
|
|
const generateItems = (n) => {
|
|
const items = [
|
|
"Cat",
|
|
"Dog",
|
|
"Elephant",
|
|
"Lion",
|
|
"Tiger",
|
|
"Giraffe",
|
|
"Dolphin",
|
|
"Penguin",
|
|
"Zebra",
|
|
"Shark",
|
|
"Whale",
|
|
"Otter",
|
|
"Crocodile",
|
|
];
|
|
|
|
const dataset = [];
|
|
|
|
for (let i = 0; i < n; i++) {
|
|
const item = items[i % items.length];
|
|
|
|
dataset.push({
|
|
label: `${item}${i}`,
|
|
value: `${item.toLowerCase()}${i}`,
|
|
description: "Sample description",
|
|
});
|
|
}
|
|
|
|
return dataset;
|
|
};
|
|
|
|
export default function App() {
|
|
const items = generateItems(1000);
|
|
|
|
return (
|
|
<div className="flex w-full flex-wrap md:flex-nowrap gap-4">
|
|
<Select
|
|
isVirtualized
|
|
className="max-w-xs"
|
|
label={"Select from 1000 items"}
|
|
maxListboxHeight={400}
|
|
placeholder="Select..."
|
|
>
|
|
{items.map((item) => (
|
|
<SelectItem key={item.value}>{item.label}</SelectItem>
|
|
))}
|
|
</Select>
|
|
</div>
|
|
);
|
|
}
|