alantoa / react-native-awesome-slider

🚀 An anwesome <Slider/> that supports various features haptic, lottie, animation, ballon, etc.
MIT License
228 stars 28 forks source link

The value of the progress bar is not refreshing. #60

Open caner219 opened 4 months ago

caner219 commented 4 months ago

When setting the value of progress for the first time, it takes effect. However, when I retrieve data from the server and want to display it on the progress bar, the progress does not refresh. How can I solve this issue?

caner219 commented 4 months ago

1708333166028

alantoa commented 4 months ago

Can you please follow the example and give it a try?

export const Example = () => {
  const progress = useSharedValue(30);
  const min = useSharedValue(0);
  const max = useSharedValue(100);
  return (
    <Slider
      style={styles.container}
      progress={progress}
      minimumValue={min}
      maximumValue={max}
    />
  );
};
caner219 commented 4 months ago

I made the changes as you suggested, but the progress bar's progress is still not refreshing. The printed value of "progressValue called with = " is changing, but the progress bar itself is still not changing. 截屏2024-02-21 上午9 50 55

alantoa commented 4 months ago

but the progress bar's progress is still not refreshing.

Are you saying that you have already dragged the thumb, but the slider did not change at all?

caner219 commented 4 months ago

When I manually drag the progress bar, that works fine. The problem is when I get the data from the server and then go to set the progress value, the progress value changes but the progress bar UI does not refresh, it stays at the initial value it was set to.

amalpsojancodiac commented 4 months ago

maybe this will help you :)

export const Example = () => {
const progress = useSharedValue(30);
 const min = useSharedValue(0);
 const max = useSharedValue(100);
  return (
    <Slider
      style={styles.container}
      progress={progress}
      minimumValue={min}
      maximumValue={max}
      cache={progress}
    />
  );
};
caner219 commented 4 months ago

Hi,I made the modifications as you instructed, but the UI of progress still has not refreshed.

caner219 commented 4 months ago

截屏2024-02-26 下午4 44 53 截屏2024-02-26 下午4 45 10

manuelxaguilar commented 3 months ago

@caner219 Any luck with this?

TikshaK commented 1 month ago

I am facing the same issue.... anyone found the solution?

alantoa commented 1 month ago

@caner219, doesn't it work for you if you set the progress SharedValue? Typically, if you only want to change the progress value, you can simply do progress.value = number;.

domalouf commented 1 month ago

I had a similar issue when trying to use the Slider inside a modal. I couldn't get the progress spot to change based on parameters passed into the modal. I think it has something to do with useSharedValue variables updating asynchronously.

Here is a link to the documentation (the first code block under remarks is where the problem comes from I think), https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue/

nrcaz commented 3 weeks ago

Having the same problem here, you can just repro the issue with a button setting the sharedValue in progress. It does not update the slider.