From 52f292445e638cb5f1ce02b5f82a5a9ba4f336af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Puissant?= Date: Thu, 6 Jun 2019 14:05:05 +0200 Subject: [PATCH 1/3] fix: read internal value of progress prop instead of using listener --- Circle.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Circle.js b/Circle.js index 571746f..b898e0a 100644 --- a/Circle.js +++ b/Circle.js @@ -57,17 +57,10 @@ export class ProgressCircle extends Component { allowFontScaling: true, }; - constructor(props, context) { - super(props, context); - - this.progressValue = 0; - } - - componentWillMount() { + componentDidMount() { if (this.props.animated) { this.props.progress.addListener(event => { - this.progressValue = event.value; - if (this.props.showsText || this.progressValue === 1) { + if (this.props.showsText || event.value === 1) { this.forceUpdate(); } }); @@ -111,7 +104,7 @@ export class ProgressCircle extends Component { const Surface = rotation ? AnimatedSurface : ART.Surface; const Shape = animated ? AnimatedArc : Arc; - const progressValue = animated ? this.progressValue : progress; + const progressValue = animated ? progress._value : progress; const angle = animated ? Animated.multiply(progress, CIRCLE) : progress * CIRCLE; @@ -190,7 +183,7 @@ export class ProgressCircle extends Component { justifyContent: 'center', }} > - {formatText(progressValue)} - + - ) : ( - false - )} + ) : false} {children} ); From faf5c43253fe8f82bbb0fc6d3326b1f34d4775bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Puissant?= Date: Thu, 6 Jun 2019 14:07:07 +0200 Subject: [PATCH 2/3] put back plain component --- Circle.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Circle.js b/Circle.js index b898e0a..7984936 100644 --- a/Circle.js +++ b/Circle.js @@ -183,7 +183,7 @@ export class ProgressCircle extends Component { justifyContent: 'center', }} > - {formatText(progressValue)} - + ) : false} {children} From 932b43995aeb7478ad0f81a5512ac15dd1487fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Puissant?= Date: Thu, 6 Jun 2019 14:34:40 +0200 Subject: [PATCH 3/3] use value getter method, add lint exception --- Circle.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Circle.js b/Circle.js index 7984936..0889034 100644 --- a/Circle.js +++ b/Circle.js @@ -104,7 +104,8 @@ export class ProgressCircle extends Component { const Surface = rotation ? AnimatedSurface : ART.Surface; const Shape = animated ? AnimatedArc : Arc; - const progressValue = animated ? progress._value : progress; + // eslint-disable-next-line no-underscore-dangle + const progressValue = animated ? progress.__getValue() : progress; const angle = animated ? Animated.multiply(progress, CIRCLE) : progress * CIRCLE;