Skip to content
This repository has been archived by the owner on Jan 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #34 from MrToph/feature/fix-deprecation-warning
Browse files Browse the repository at this point in the history
Fix cWRP deprecation warning by not using state
  • Loading branch information
MrToph authored Oct 24, 2019
2 parents dfc5c39 + 9c79610 commit e3866ac
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,8 @@ export default class PercentageCircle extends Component {
containerStyle: null,
};

constructor(props) {
super(props)
this.state = this.getInitialStateFromProps(props)
}

componentWillReceiveProps(nextProps) {
this.setState(this.getInitialStateFromProps(nextProps))
}

getInitialStateFromProps(props) {
computeDerivedState() {
const { props } = this;
const percent = Math.max(Math.min(100, props.percent), 0)
const needHalfCircle2 = percent > 50
let halfCircle1Degree
Expand Down Expand Up @@ -153,7 +145,8 @@ export default class PercentageCircle extends Component {
halfCircle1Degree,
halfCircle2Degree,
halfCircle2Styles,
} = this.state
} = this.computeDerivedState()

return (
<View
style={[
Expand Down

0 comments on commit e3866ac

Please sign in to comment.