mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-04 18:59:08 +01:00
memoized
This commit is contained in:
parent
af175f68e2
commit
f5c0503d1f
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import clsx from "clsx";
|
||||
import React, { useState } from "react";
|
||||
import React, { memo, useState } from "react";
|
||||
import "./list.less";
|
||||
|
||||
interface ListItem {
|
||||
@ -18,7 +18,7 @@ interface ListProps {
|
||||
renderItem?: (item: ListItem, isOpen: boolean, handleClick: () => void) => React.ReactNode;
|
||||
}
|
||||
|
||||
const List = ({ items, className, renderItem }: ListProps) => {
|
||||
const List = memo(({ items, className, renderItem }: ListProps) => {
|
||||
const [open, setOpen] = useState<{ [key: string]: boolean }>({});
|
||||
|
||||
const handleClick = (item: ListItem) => {
|
||||
@ -57,6 +57,6 @@ const List = ({ items, className, renderItem }: ListProps) => {
|
||||
};
|
||||
|
||||
return <ul className="list">{items.map((item, index) => renderListItem(item, index))}</ul>;
|
||||
};
|
||||
});
|
||||
|
||||
export { List };
|
||||
|
Loading…
Reference in New Issue
Block a user