react-native-progress icon indicating copy to clipboard operation
react-native-progress copied to clipboard

Wrong text in Circle when `animated` is true

Open alexcouret opened this issue 8 years ago • 16 comments

Hello,

I have an issue where the text inside the circle is always at 0 if I don't setanimated={false}. After looking at the code, it seems like this code is responsible :

componentWillMount() {
    if (this.props.animated) {
      this.props.progress.addListener((event) => {
        this.progressValue = event.value;
        if (this.props.showsText || this.progressValue === 1) {
          this.forceUpdate();
        }
      });
    }
  }

It's never entering the listener (I put some logs), so the progressValue is always 0.

Thanks.

alexcouret avatar Jul 19 '17 13:07 alexcouret

I'm having the same issue. Is there a solution coming for this? Thanks.

jaesius avatar Sep 02 '17 19:09 jaesius

Hi there, I had the same issue. After some digging and experimenting, I got it to work by changing

{formatText(progressValue)}

in line 187 at Circle.js (node_modules\react-native-progress\Circle.js) to

{progress ? formatText(progress._value) : this.forceUpdate()}

Hope it helps.

phantom1299 avatar Nov 08 '17 18:11 phantom1299

Same issue :(

lossen avatar Nov 17 '17 05:11 lossen

Is this issue solved? Still facing it...

Ashwin-Mothilal avatar Jan 18 '18 13:01 Ashwin-Mothilal

This issue is still not fixed, and it is very simple to fix...

@phantom1299 has found the solution to the problem about 4 months ago and it is still not fix.

LolnationCH avatar Mar 01 '18 22:03 LolnationCH

Still facing this issue. The PR is pending, any news about this ?

Clafouti avatar May 28 '18 08:05 Clafouti

@Clafouti You need to modify it yourself, the author does not seem to code on this anymore. You could always fork it and make it better :)

LolnationCH avatar May 28 '18 16:05 LolnationCH

@LolnationCH I'm unable to reproduce this bug, can you post a minimal example code to reproduce?

oblador avatar May 31 '18 18:05 oblador

export default class CharacterInfoView extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
                  exp: 0.0,
  }
render() {
    return(
<View>
<Progress.Circle size={30}
       showsText={true}
       size={150}
       progress={this.state.exp}
       borderWidth={0}
       color={'rgb(0, 255, 25)'}
       unfilledColor={'rgb(121, 119, 119)'}/>
<TextInput
                style={styles.textInput}
                placeholder="seconds"
                keyboardType='numeric'
                onChangeText={(exp) => this.setState({exp: exp})}/>
</View>
);}}

I did not test this, but it's an adaptation of my code link that I had to do the modification, otherwise it wouldn't work.

Using : "react-native-progress": "^3.4.0" (package.json)

LolnationCH avatar May 31 '18 20:05 LolnationCH

@LolnationCH The problem with your code is that you are passing a string, not a number. If you replace it with onChangeText={exp => this.setState({ exp: parseFloat(exp, 10) || 0 })} then it works just fine for me.

oblador avatar May 31 '18 22:05 oblador

Still happens when its a number, this was just a example, not what im actually doing. I call a function that sets exp to a float.

LolnationCH avatar May 31 '18 23:05 LolnationCH

It's really hard for me to fix if I can't reproduce, the code you just posted works fine if you fix the string bug. Could you set up an example project that demonstrates this?

oblador avatar Jun 01 '18 07:06 oblador

The issue still occurs, @oblador with string or float. Also, @phantom1299 temporary-fix causes onChangeText to stop working.

yakirbu avatar Jun 11 '18 09:06 yakirbu

@oblador minimum code is:

import * as Progress from 'react-native-progress';

class SomethingNew extends PureComponent {
  render() {
    return (
      <Progress.Circle
        progress={0.67}
        showsText={true}
      />
    );
  }
}

Will be shown zero.

UPD: screenshots image *Sorry for tripled elem

Doodidan avatar Jun 26 '18 17:06 Doodidan

same here!

stlemon avatar Jul 17 '18 13:07 stlemon

The PR #117 solved this issue to me

rfbezerra avatar Aug 29 '18 19:08 rfbezerra