Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isActive doesn't reliably change to false at the end of a gesture #263

Open
stevengoldberg opened this issue May 10, 2024 · 1 comment
Open

Comments

@stevengoldberg
Copy link

Describe Your Environment

What version of victory-native-xl are you using? 40.1.1

What version of React and React Native are you using? react 18.2.0, react-native 0.73.6

What version of Reanimated and React Native Skia are you using? reanimated 3.8.1, skia 0.1.221

Are you using Expo or React Native CLI? expo

What platform are you on? (e.g., iOS, Android) iOS

Describe the Problem

When performing a pan gesture on a CartesianChart, isActive sometimes remains true at the end of the gesture. I was able to reproduce this issue in the example app. My app implements very similar logic.

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-05-09.at.16.31.57.mp4

Expected behavior: At the end of the gesture, isActive should become false and the text below the chart should revert to "Single or multi-touch the chart"

Actual behavior: isActive sometimes remains true at the end of the gesture, so that the text below the chart continues to display the last-touched value.

@stevengoldberg
Copy link
Author

stevengoldberg commented May 10, 2024

Actually after experimenting some more I'm not sure the value of isActive is actually the problem here. It seems like there's some other race condition happening.

edit: I believe the problem is actually with the implementation of AnimatedText in the example app.

Passing an initialValue string instead of value={text.value} seems to prevent the issue.

import * as React from "react";
import { TextInput, type TextInputProps } from "react-native";
import Reanimated, {
  useAnimatedProps,
  type SharedValue,
} from "react-native-reanimated";

const AnimText = Reanimated.createAnimatedComponent(TextInput);
Reanimated.addWhitelistedNativeProps({ text: true });

type AnimatedTextProps = Omit<TextInputProps, "editable" | "value"> & {
  text: SharedValue<string>;
  initialValue: string;
  style?: React.ComponentProps<typeof AnimText>["style"];
};

export function AnimatedText({
  text,
  initialValue,
  ...rest
}: AnimatedTextProps) {
  const animProps = useAnimatedProps(() => {
    return {
      text: text.value,
    };
  });

  return (
    <AnimText
      {...rest}
      value={initialValue}
      // @ts-ignore
      animatedProps={animProps}
      editable={false}
    />
  );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant