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

Wrong text in Circle when animated is true #67

Open
alexcouret opened this issue Jul 19, 2017 · 16 comments
Open

Wrong text in Circle when animated is true #67

alexcouret opened this issue Jul 19, 2017 · 16 comments

Comments

@alexcouret
Copy link

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.

@jaesius
Copy link

jaesius commented Sep 2, 2017

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

@phantom1299
Copy link

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.

@lossen
Copy link

lossen commented Nov 17, 2017

Same issue :(

@Ashwin-Mothilal
Copy link

Is this issue solved? Still facing it...

@LolnationCH
Copy link

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.

@Clafouti
Copy link

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

@LolnationCH
Copy link

@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 :)

@oblador
Copy link
Owner

oblador commented May 31, 2018

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

@LolnationCH
Copy link

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)

@oblador
Copy link
Owner

oblador commented May 31, 2018

@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.

@LolnationCH
Copy link

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.

@oblador
Copy link
Owner

oblador commented Jun 1, 2018

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?

@yakirbu
Copy link

yakirbu commented Jun 11, 2018

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

@Doodidan
Copy link

Doodidan commented Jun 26, 2018

@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

@stlemon
Copy link

stlemon commented Jul 17, 2018

same here!

@rfbezerra
Copy link

The PR #117 solved this issue to me

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