mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-10 20:32:21 +08:00
chore(eslint): add eslint-plugin-react-compiler (#5918)
* chore(eslint): add `eslint-plugin-react-compiler` * refactor: fix eslint warnings and avoid in-render mutations --------- Co-authored-by: Slinetrac <realakayuki@gmail.com>
This commit is contained in:
@@ -88,25 +88,19 @@ export const WebUIItem = (props: Props) => {
|
||||
);
|
||||
}
|
||||
|
||||
const placeholderCounts: Record<string, number> = {};
|
||||
let textCounter = 0;
|
||||
const renderedParts = highlightedParts.map((part) => {
|
||||
const renderedParts = highlightedParts.map((part, index) => {
|
||||
const isPlaceholder =
|
||||
part === "%host" || part === "%port" || part === "%secret";
|
||||
const repeatIndex = highlightedParts
|
||||
.slice(0, index)
|
||||
.filter((prev) => prev === part).length;
|
||||
const key = `${part || "empty"}-${repeatIndex}`;
|
||||
|
||||
if (isPlaceholder) {
|
||||
const count = placeholderCounts[part] ?? 0;
|
||||
placeholderCounts[part] = count + 1;
|
||||
return (
|
||||
<span key={`placeholder-${part}-${count}`} className="placeholder">
|
||||
{part}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
const key = `text-${textCounter}-${part || "empty"}`;
|
||||
textCounter += 1;
|
||||
return <span key={key}>{part}</span>;
|
||||
return (
|
||||
<span key={key} className={isPlaceholder ? "placeholder" : undefined}>
|
||||
{part}
|
||||
</span>
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user