diff --git a/UPGRADING.md b/UPGRADING.md index 26a5486..86040f8 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,3 +1,55 @@ +# Migration guide for major versions + +## 1.x.x to 2.0.0 + +**Use a named import to import CircularProgressbar** + +Before: + +```jsx +import CircularProgressbar from 'react-circular-progressbar'; +``` + +After: + +```jsx +import { CircularProgressbar } from 'react-circular-progressbar'; +``` + +**Use `props.value` instead of `props.percentage`** + +Before: + +```jsx + +``` + +After: + +```jsx + +``` + +**Replace `props.initialAnimation` with a wrapper component** + +This is only applicable if you're using `props.initialAnimation`, which is removed in v2.0.0. Instead, you must trigger the animation by changing `value` from one value to another yourself. + +Before: + +```jsx + +``` + +After: + +You'll need a wrapper component to help manage the value transition. See [ProgressProvider.tsx](demo/src/ProgressProvider.tsx) for an example. Once you have that, you can do: + +```jsx + + {(value) => } + +``` + ## 0.x.x to 1.0.0 The main breaking change is the replacement of the `classForPercentage` prop with `className`, and the `textForPercentage` prop with `text` [#61]. diff --git a/demo/src/Demo.tsx b/demo/src/Demo.tsx index 2b2a382..9ea5d5b 100644 --- a/demo/src/Demo.tsx +++ b/demo/src/Demo.tsx @@ -172,11 +172,11 @@ function Demo() { } > - - {(percentage) => ( + + {(value) => ( React.ReactNode; + valueStart: number; + valueEnd: number; + children: (value: number) => React.ReactNode; }; type State = { - percentage: number; + value: number; }; class ProgressProvider extends React.Component { timeout: number | undefined = undefined; state = { - percentage: this.props.percentageStart, + value: this.props.valueStart, }; static defaultProps = { - percentageStart: 0, + valueStart: 0, }; componentDidMount() { this.timeout = window.setTimeout(() => { this.setState({ - percentage: this.props.percentageEnd, + value: this.props.valueEnd, }); }, 0); } @@ -35,7 +35,7 @@ class ProgressProvider extends React.Component { } render() { - return this.props.children(this.state.percentage); + return this.props.children(this.state.value); } }