react-countup
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -131,3 +131,4 @@ 'use strict'; | ||
suffix = _props.suffix, | ||
style = _props.style; | ||
style = _props.style, | ||
formattingFn = _props.formattingFn; | ||
@@ -138,3 +139,3 @@ | ||
{ className: className, ref: this.refSpan, style: style }, | ||
formatNumber(start, { | ||
typeof formattingFn === 'function' ? formattingFn(start) : formatNumber(start, { | ||
decimal: decimal, | ||
@@ -141,0 +142,0 @@ decimals: decimals, |
{ | ||
"name": "react-countup", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "A React component wrapper around CountUp.js", | ||
@@ -45,9 +45,8 @@ "author": "Glenn Reyes <glenn@glennreyes.com> (https://twitter.com/glnnrys)", | ||
"devDependencies": { | ||
"babel-cli": "^6.24.1", | ||
"babel-cli": "^6.26.0", | ||
"babel-eslint": "^8.0.2", | ||
"babel-plugin-transform-flow-strip-types": "6.22.0", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-react": "^6.24.1", | ||
"babel-preset-stage-2": "6.24.1", | ||
"eslint": "^4.10.0", | ||
"babel-preset-stage-2": "^6.24.1", | ||
"eslint": "^4.11.0", | ||
"eslint-config-airbnb": "^16.1.0", | ||
@@ -58,13 +57,13 @@ "eslint-config-prettier": "^2.7.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.2", | ||
"eslint-plugin-react": "^7.2.0", | ||
"flow-bin": "^0.58.0", | ||
"eslint-plugin-react": "^7.4.0", | ||
"flow-bin": "^0.59.0", | ||
"husky": "^0.14.3", | ||
"jest": "^21.2.1", | ||
"lint-staged": "^4.3.0", | ||
"prettier": "^1.8.1", | ||
"lint-staged": "^5.0.0", | ||
"prettier": "^1.8.2", | ||
"raf": "^3.4.0", | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0", | ||
"react-test-renderer": "^16.0.0" | ||
"react": "^16.1.1", | ||
"react-dom": "^16.1.1", | ||
"react-test-renderer": "^16.1.1" | ||
} | ||
} |
@@ -22,4 +22,2 @@ # [React CountUp](https://glennreyes.github.io/react-countup) | ||
Make sure you have a compatible version of React `15.x.x` installed in your project. | ||
```bash | ||
@@ -26,0 +24,0 @@ yarn add react-countup |
@@ -26,2 +26,15 @@ import React from 'react'; | ||
it('renders correctly with formattingFn', () => { | ||
const createNodeMock = () => ({ startAnimation }); | ||
const tree = renderer | ||
.create( | ||
<CountUp start={0} end={10} formattingFn={v => `formated:${v}`} />, | ||
{ | ||
createNodeMock, | ||
}, | ||
) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
it('should update on new duration', () => { | ||
@@ -28,0 +41,0 @@ const node = document.createElement('div'); |
@@ -14,3 +14,3 @@ // @flow | ||
end: number, | ||
formattingFn: () => void, | ||
formattingFn: (start: number) => string, | ||
onComplete: () => void, | ||
@@ -163,2 +163,3 @@ onStart: () => void, | ||
style, | ||
formattingFn, | ||
} = this.props; | ||
@@ -168,9 +169,11 @@ | ||
<span className={className} ref={this.refSpan} style={style}> | ||
{formatNumber(start, { | ||
decimal, | ||
decimals, | ||
separator, | ||
prefix, | ||
suffix, | ||
})} | ||
{typeof formattingFn === 'function' | ||
? formattingFn(start) | ||
: formatNumber(start, { | ||
decimal, | ||
decimals, | ||
separator, | ||
prefix, | ||
suffix, | ||
})} | ||
</span> | ||
@@ -177,0 +180,0 @@ ); |
Sorry, the diff of this file is not supported yet
19540
21
383
160