homielab / react-native-auto-scroll

A performance auto horizontal scrolling component for react-native
https://www.npmjs.com/package/@homielab/react-native-auto-scroll
218 stars 23 forks source link

Animation stoping when navigate to another screen #23

Open matheuscasavechia opened 2 years ago

matheuscasavechia commented 2 years ago

Hi everyone, I'm having a problem with te animation... I use the same component exporting it to use in another screen and the component is using AutoScroll, but when i navigate to another screen, and this has the component i'm exporting, the animation stop... Can you guys help me ?

bhyoo99 commented 2 years ago

Can you provide me with a more accurate environment or code to check the issue?

matheuscasavechia commented 2 years ago

�Can you provide me with a more accurate environment or code to check the issue?

Like, i have a component that is using the tag AutoScroll, and this component i use an many screen in my app. When i'm in the home screen of my app (in this screen i declare the component), and navigate to another screen, screen that have the component, the AutoScroll stop the scroll, to get the scroll work again i need to retry the same flow, many times until they appear start working again... but when i continue testing the scroll stop again and i need to do the flow again to get the component working again.

kmlrmdhn commented 1 year ago

@matheuscasavechia did you find solution about this error?

julien-ctx commented 1 year ago

I had the same problem and I fixed it by deleting the following code snippet from index.tsx:

React.useEffect(() => {
    return () => {
      contentRef.current = null;
    };
  });

Depending on how you setup your app, it appears that contentRef.current can be null even though you have data in your children components. React is apparently already setting contentRef.current to null when the component is unmounted.

kmlrmdhn commented 1 year ago

@julien-ctx it works, thanks man.

minhtc commented 1 year ago

I had the same problem and I fixed it by deleting the following code snippet from index.tsx:

React.useEffect(() => {
    return () => {
      contentRef.current = null;
    };
  });

Depending on how you setup your app, it appears that contentRef.current can be null even though you have data in your children components. React is apparently already setting contentRef.current to null when the component is unmounted.

Thank you. Can you help me by make a pull request?