mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-19 09:30:08 +02:00
fix(ReorderableList): avoid mutating props (#109)
Co-authored-by: AAGaming <aagaming@riseup.net> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
@@ -35,12 +35,12 @@ export type ReorderableListProps<T> = {
|
||||
export function ReorderableList<T>(props: ReorderableListProps<T>) {
|
||||
if (props.animate === undefined) props.animate = true;
|
||||
const [entryList, setEntryList] = useState<ReorderableEntry<T>[]>(
|
||||
props.entries.sort((a: ReorderableEntry<T>, b: ReorderableEntry<T>) => a.position - b.position),
|
||||
[...props.entries].sort((a: ReorderableEntry<T>, b: ReorderableEntry<T>) => a.position - b.position),
|
||||
);
|
||||
const [reorderEnabled, setReorderEnabled] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
setEntryList(props.entries.sort((a: ReorderableEntry<T>, b: ReorderableEntry<T>) => a.position - b.position));
|
||||
setEntryList([...props.entries].sort((a: ReorderableEntry<T>, b: ReorderableEntry<T>) => a.position - b.position));
|
||||
}, [props.entries]);
|
||||
|
||||
function toggleReorderEnabled(): void {
|
||||
|
||||
Reference in New Issue
Block a user