Skip to content

Commit

Permalink
Improve AbilitySelector responsiveness on slower machines
Browse files Browse the repository at this point in the history
  • Loading branch information
Sendouc committed Oct 15, 2023
1 parent 2404d10 commit beaf0ce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/components/AbilitiesSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from "clsx";
import React from "react";
import * as React from "react";
import invariant from "tiny-invariant";
import { abilities } from "~/modules/in-game-lists";
import type { BuildAbilitiesTupleWithUnknown } from "~/modules/in-game-lists/types";
Expand All @@ -16,6 +16,8 @@ export function AbilitiesSelector({
selectedAbilities,
onChange,
}: AbilitiesSelectorProps) {
const [, startTransition] = React.useTransition();

const onSlotClick = ({
rowI,
abilityI,
Expand All @@ -39,7 +41,9 @@ export function AbilitiesSelector({
onChange(abilitiesClone);
};
const onButtonClick = (ability: (typeof abilities)[number]) => {
onChange(addAbility({ oldAbilities: selectedAbilities, ability }));
startTransition(() => {
onChange(addAbility({ oldAbilities: selectedAbilities, ability }));
});
};

const [draggingAbility, setDraggingAbility] = React.useState<
Expand Down

0 comments on commit beaf0ce

Please sign in to comment.