Skip to content

Commit

Permalink
fix: Flop 組件在格式化后可能出现不重新渲染的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoKam committed Aug 5, 2023
1 parent f6d4466 commit 9c0e9b9
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 19 deletions.
6 changes: 6 additions & 0 deletions packages/antd-plus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @orca-fe/painter

## 0.2.1

### Patch Changes

- update dependencies

## 0.2.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/antd-plus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/antd-plus",
"version": "0.2.0",
"version": "0.2.1",
"description": "Transformer Container",
"keywords": [
"react",
Expand Down Expand Up @@ -38,7 +38,7 @@
"dependencies": {
"@orca-fe/hooks": "^1.8.6",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/pocket": "^3.2.0",
"@orca-fe/pocket": "^3.2.1",
"@orca-fe/simple-jss": "^0.0.3",
"@orca-fe/tools": "^0.10.0",
"ahooks": "^3.7.8",
Expand Down
6 changes: 6 additions & 0 deletions packages/painter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @orca-fe/painter

## 1.4.35

### Patch Changes

- update dependencies

## 1.4.34

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/painter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/painter",
"version": "1.4.34",
"version": "1.4.35",
"description": "Konva Painter",
"keywords": [
"react",
Expand Down Expand Up @@ -39,7 +39,7 @@
"dependencies": {
"@orca-fe/hooks": "^1.8.6",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/pocket": "^3.2.0",
"@orca-fe/pocket": "^3.2.1",
"@orca-fe/simple-jss": "^0.0.3",
"@orca-fe/tools": "^0.10.0",
"ahooks": "^3.7.8",
Expand Down
8 changes: 8 additions & 0 deletions packages/pdf-viewer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @orca-fe/pdf-viewer

## 1.16.14

### Patch Changes

- update dependencies
- Updated dependencies
- @orca-fe/painter@1.4.35

## 1.16.13

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/pdf-viewer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/pdf-viewer",
"version": "1.16.13",
"version": "1.16.14",
"description": "PDF Viewer",
"keywords": [
"react",
Expand Down Expand Up @@ -40,9 +40,9 @@
"dependencies": {
"@orca-fe/hooks": "^1.8.6",
"@orca-fe/jss-plugin-auto-prefix": "^0.0.1",
"@orca-fe/painter": "^1.4.34",
"@orca-fe/painter": "^1.4.35",
"@orca-fe/pdfjs-dist-browserify": "^3.8.24",
"@orca-fe/pocket": "^3.2.0",
"@orca-fe/pocket": "^3.2.1",
"@orca-fe/simple-jss": "^0.0.3",
"@orca-fe/tools": "^0.10.0",
"ahooks": "^3.7.8",
Expand Down
6 changes: 6 additions & 0 deletions packages/pocket/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @orca-fe/pocket

## 3.2.1

### Patch Changes

- fix: Flop 組件在格式化后可能出现不重新渲染的 bug

## 3.2.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/pocket/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/pocket",
"version": "3.2.0",
"version": "3.2.1",
"description": "UI components by orca-team",
"keywords": [
"react",
Expand Down
19 changes: 18 additions & 1 deletion packages/pocket/src/flop/Flop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,32 @@ const Flop = React.forwardRef<HTMLSpanElement, FlopProps>((props, ref) => {
decimalPlaces: decimals ?? decimalLength(valueUnit.value),
});
_this.countup.start();
window.countup = _this.countup;
}
}
}, []);

useUpdateEffect(() => {
if (_this.countup?.options) {
_this.countup.options.duration = duration;
_this.countup.reset();
}
}, [duration]);

useUpdateEffect(() => {
if (_this.countup?.options) {
_this.countup.options.separator = separator;
}
}, [separator]);

useUpdateEffect(() => {
if (_this.countup) {
if (_this.countup.options) {
_this.countup.options.decimalPlaces = decimals ?? decimalLength(valueUnit.value);
}
_this.countup.update(valueUnit.value);
}
}, [valueUnit.value]);
}, [valueUnit]);

return (
<span ref={ref} className={`${styles.root} ${className}`} {...otherProps}>
Expand Down
15 changes: 10 additions & 5 deletions packages/pocket/src/flop/demo/Demo1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,24 @@ import { Flop } from '@orca-fe/pocket';
import { useInterval } from '@orca-fe/hooks';

const Demo = () => {
const [value, setValue] = useState(12345);
const [value, setValue] = useState(123);
useInterval(() => {
let num = Math.random() * 10000;
if (Math.random() > 0.5) {
num *= 10000;
if (Math.random() > 0.7) {
num *= 1000;
}
if (Math.random() > 0.7) {
num *= 1000;
}
if (Math.random() > 0.5) {
num *= Math.trunc(Math.random() * 10000);
num *= Math.random() * 10000;
}
setValue(num);
setValue(Math.trunc(num));
}, 3000);
return (
<div>
<Flop value={value} />
<br />
<Flop value={value} convertUnit={false} />
<br />
<Flop value={value} convertUnit={false} decimals={2} />
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit 9c0e9b9

@vercel
Copy link

@vercel vercel bot commented on 9c0e9b9 Aug 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.