Skip to content

A local-first personal finance app

Upgrade react-spring, remove wobble (#1043)

Jed Fox19af0b36a2a2
diff --git a/packages/desktop-client/package.json b/packages/desktop-client/package.json
index dfe5f5bf58..a07e914f15 100644
--- a/packages/desktop-client/package.json
+++ b/packages/desktop-client/package.json
@@ -52,12 +52,11 @@
"react-router-dom": "5.2.0",
"react-router-dom-v5-compat": "^6.4.1",
"react-scripts": "^5.0.1",
- "react-spring": "^8.0.27",
+ "react-spring": "^9.7.1",
"react-virtualized-auto-sizer": "^1.0.2",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
- "victory": "^36.6.8",
- "wobble": "^1.5.0"
+ "victory": "^36.6.8"
},
"scripts": {
"start": "cross-env PORT=3001 react-app-rewired start",
diff --git a/packages/desktop-client/src/components/BankSyncStatus.js b/packages/desktop-client/src/components/BankSyncStatus.js
index 467b097e50..36c8d25af8 100644
--- a/packages/desktop-client/src/components/BankSyncStatus.js
+++ b/packages/desktop-client/src/components/BankSyncStatus.js
@@ -16,7 +16,7 @@ function BankSyncStatus({ accountsSyncing }) {
: accountsSyncing
: null;
- const transitions = useTransition(name, null, {
+ const transitions = useTransition(name, {
from: { opacity: 0, transform: 'translateY(-100px)' },
enter: { opacity: 1, transform: 'translateY(0)' },
leave: { opacity: 0, transform: 'translateY(-100px)' },
@@ -35,10 +35,10 @@ function BankSyncStatus({ accountsSyncing }) {
zIndex: 501,
}}
>
- {transitions.map(
- ({ item, key, props }) =>
+ {transitions(
+ (style, item) =>
item && (
- <animated.div key={key} style={props}>
+ <animated.div key={item} style={style}>
<View
style={{
borderRadius: 4,
diff --git a/packages/desktop-client/src/components/budget/BudgetSummaries.js b/packages/desktop-client/src/components/budget/BudgetSummaries.js
index c280a3153a..ddb247061b 100644
--- a/packages/desktop-client/src/components/budget/BudgetSummaries.js
+++ b/packages/desktop-client/src/components/budget/BudgetSummaries.js
@@ -5,9 +5,9 @@ import React, {
useCallback,
useLayoutEffect,
} from 'react';
+import { useSpring, animated } from 'react-spring';
import { css } from 'glamor';
-import { Spring } from 'wobble';
import * as monthUtils from 'loot-core/src/shared/months';
@@ -20,14 +20,16 @@ export default function BudgetSummaries({ SummaryComponent }) {
let { months } = useContext(MonthsContext);
let [widthState, setWidthState] = useState(0);
- let spring = useRef(null);
+ let [styles, spring] = useSpring(() => ({
+ x: 0,
+ config: { mass: 3, tension: 600, friction: 80 },
+ }));
let containerRef = useResizeObserver(
useCallback(rect => {
setWidthState(rect.width);
}, []),
);
- let scrollerRef = useRef();
let prevMonth0 = useRef(months[0]);
@@ -37,37 +39,15 @@ export default function BudgetSummaries({ SummaryComponent }) {
let monthWidth = widthState / months.length;
useLayoutEffect(() => {
- if (!scrollerRef.current) {
- return;
- }
-
- if (!spring.current) {
- spring.current = new Spring({
- stiffness: 600,
- damping: 80,
- mass: 3,
- fromValue: -monthWidth,
- });
-
- spring.current.onUpdate(s => {
- if (scrollerRef.current) {
- scrollerRef.current.style.transform =
- 'translateX(' + s.currentValue + 'px)';
- }
- });
- }
-
let prevMonth = prevMonth0.current;
let reversed = prevMonth > months[0];
let offsetX = monthWidth;
-
let from = reversed ? -offsetX * 2 : 0;
if (prevMonth !== allMonths[0] && prevMonth !== allMonths[2]) {
from = -offsetX;
}
-
let to = -offsetX;
- spring.current.updateConfig({ fromValue: from, toValue: to }).start();
+ spring.start({ from: { x: from }, x: to });
}, [months[0]]);
useLayoutEffect(() => {
@@ -75,7 +55,7 @@ export default function BudgetSummaries({ SummaryComponent }) {
}, [months[0]]);
useLayoutEffect(() => {
- scrollerRef.current.style.transform = `translateX(${-monthWidth}px)`;
+ spring.start({ from: { x: -monthWidth }, to: { x: -monthWidth } });
}, [monthWidth]);
return (
@@ -89,15 +69,16 @@ export default function BudgetSummaries({ SummaryComponent }) {
])}
ref={containerRef}
>
- <View
+ <animated.div
+ className="view"
style={{
flexDirection: 'row',
width: widthState,
willChange: 'transform',
+ transform: styles.x.to(x => `translateX(${x}px)`),
}}
- innerRef={scrollerRef}
>
- {allMonths.map((month, idx) => {
+ {allMonths.map(month => {
return (
<View
key={month}
@@ -110,7 +91,7 @@ export default function BudgetSummaries({ SummaryComponent }) {
</View>
);
})}
- </View>
+ </animated.div>
</div>
);
}
diff --git a/upcoming-release-notes/1043.md b/upcoming-release-notes/1043.md
new file mode 100644
index 0000000000..19dbc6e7e9
--- /dev/null
+++ b/upcoming-release-notes/1043.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [j-f1]
+---
+
+Upgrade `react-spring`, remove `wobble` dependency
diff --git a/yarn.lock b/yarn.lock
index 55f75cac6b..987c342b7a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -101,12 +101,11 @@ __metadata:
react-router-dom: 5.2.0
react-router-dom-v5-compat: ^6.4.1
react-scripts: ^5.0.1
- react-spring: ^8.0.27
+ react-spring: ^9.7.1
react-virtualized-auto-sizer: ^1.0.2
redux: ^4.0.5
redux-thunk: ^2.3.0
victory: ^36.6.8
- wobble: ^1.5.0
languageName: unknown
linkType: soft
@@ -1595,7 +1594,7 @@ __metadata:
languageName: node
linkType: hard
-"@babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.1, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.14.8, @babel/runtime@npm:^7.16.3, @babel/runtime@npm:^7.20.7, @babel/runtime@npm:^7.3.1, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.6.2, @babel/runtime@npm:^7.7.6, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.9.2":
+"@babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.1, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.14.8, @babel/runtime@npm:^7.16.3, @babel/runtime@npm:^7.20.7, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.6.2, @babel/runtime@npm:^7.7.6, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.9.2":
version: 7.21.0
resolution: "@babel/runtime@npm:7.21.0"
dependencies:
@@ -2866,6 +2865,137 @@ __metadata:
languageName: node
linkType: hard
+"@react-spring/animated@npm:~9.7.2":
+ version: 9.7.2
+ resolution: "@react-spring/animated@npm:9.7.2"
+ dependencies:
+ "@react-spring/shared": ~9.7.2
+ "@react-spring/types": ~9.7.2
+ peerDependencies:
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ checksum: 08f2f1e54468776b2abf76e3c3504129b8d965875781bc1cfd40adddff8f310869ecfb6d18e937df8ed63a01b3d0cb2335fb531be03ddf25f6f58583a91e08e7
+ languageName: node
+ linkType: hard
+
+"@react-spring/core@npm:~9.7.1, @react-spring/core@npm:~9.7.2":
+ version: 9.7.2
+ resolution: "@react-spring/core@npm:9.7.2"
+ dependencies:
+ "@react-spring/animated": ~9.7.2
+ "@react-spring/rafz": ~9.7.2
+ "@react-spring/shared": ~9.7.2
+ "@react-spring/types": ~9.7.2
+ peerDependencies:
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ checksum: 7d14369d6bc3cb4f51bce946a0499484bd03a06b2602edd1f0478806759fd2a5f0800892cdf8d38a3bd4ef949f3c61de65933c46784683ea757f16db710a04fd
+ languageName: node
+ linkType: hard
+
+"@react-spring/konva@npm:~9.7.1":
+ version: 9.7.2
+ resolution: "@react-spring/konva@npm:9.7.2"
+ dependencies:
+ "@react-spring/animated": ~9.7.2
+ "@react-spring/core": ~9.7.2
+ "@react-spring/shared": ~9.7.2
+ "@react-spring/types": ~9.7.2
+ peerDependencies:
+ konva: ">=2.6"
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ react-konva: ^16.8.0 || ^16.8.7-0 || ^16.9.0-0 || ^16.10.1-0 || ^16.12.0-0 || ^16.13.0-0 || ^17.0.0-0 || ^17.0.1-0 || ^17.0.2-0 || ^18.0.0-0
+ checksum: de1819722d578355a51b7e70509adde747650c22df7540a81b989a423292110b606e5675d41e70cce332b528bfe62e9b56571ed70acf72896014f8c852b2a777
+ languageName: node
+ linkType: hard
+
+"@react-spring/native@npm:~9.7.1":
+ version: 9.7.2
+ resolution: "@react-spring/native@npm:9.7.2"
+ dependencies:
+ "@react-spring/animated": ~9.7.2
+ "@react-spring/core": ~9.7.2
+ "@react-spring/shared": ~9.7.2
+ "@react-spring/types": ~9.7.2
+ peerDependencies:
+ react: ^16.8.0 || >=17.0.0 || >=18.0.0
+ react-native: ">=0.58"
+ checksum: 11963f7c9993f1c34bd32f82a1425f9e50d83c86f28ff53940aed87c677732d11e379e596fd2728861b5d8978255496eb63769d54018f943f15f6d80628e17a0
+ languageName: node
+ linkType: hard
+
+"@react-spring/rafz@npm:~9.7.2":
+ version: 9.7.2
+ resolution: "@react-spring/rafz@npm:9.7.2"
+ checksum: 88ad6275ed172745c7cd309e6a06bb52b76b6f391510afcf8ad12d1fc50950e74f902f96bcaae0895ab75e47a1d809d36fe843ce8d3d0d2ea2d6700ff9e03d81
+ languageName: node
+ linkType: hard
+
+"@react-spring/shared@npm:~9.7.2":
+ version: 9.7.2
+ resolution: "@react-spring/shared@npm:9.7.2"
+ dependencies:
+ "@react-spring/rafz": ~9.7.2
+ "@react-spring/types": ~9.7.2
+ peerDependencies:
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ checksum: f3041a537dddad63c64e68890f3276b72c4e2d5828621a09dbd722edb7a12edc0026555118f8305b969253f44e409ddd411dd5b99ec4e04edea32bee5e5f57fd
+ languageName: node
+ linkType: hard
+
+"@react-spring/three@npm:~9.7.1":
+ version: 9.7.2
+ resolution: "@react-spring/three@npm:9.7.2"
+ dependencies:
+ "@react-spring/animated": ~9.7.2
+ "@react-spring/core": ~9.7.2
+ "@react-spring/shared": ~9.7.2
+ "@react-spring/types": ~9.7.2
+ peerDependencies:
+ "@react-three/fiber": ">=6.0"
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ three: ">=0.126"
+ checksum: 970efd0fb7eee29edc0f468fde3ab590905cd9136e6f1a017dc40b9b94dc1bf1befe399ac08848994b1359f83339be93b09eb5b30f9f2ff97f9f0477bb4de45c
+ languageName: node
+ linkType: hard
+
+"@react-spring/types@npm:~9.7.2":
+ version: 9.7.2
+ resolution: "@react-spring/types@npm:9.7.2"
+ checksum: 145a79d2f40dfc9f0a4b54db17890c6471b4e50563c01951ca13022977b0d8009865c1839cf07a762fd33ae0b83f2d6972e2d0fe50bd3105942b9cea5253612e
+ languageName: node
+ linkType: hard
+
+"@react-spring/web@npm:~9.7.1":
+ version: 9.7.2
+ resolution: "@react-spring/web@npm:9.7.2"
+ dependencies:
+ "@react-spring/animated": ~9.7.2
+ "@react-spring/core": ~9.7.2
+ "@react-spring/shared": ~9.7.2
+ "@react-spring/types": ~9.7.2
+ peerDependencies:
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
+ checksum: f872dfd9bbbfc27f32e4406076729a36169e2da3785709fbf981b7d3a77a1a430d7f295b300a9acc8cb4805d0965e6d9a54914a4263abfd96806b7ae53ba69cd
+ languageName: node
+ linkType: hard
+
+"@react-spring/zdog@npm:~9.7.1":
+ version: 9.7.2
+ resolution: "@react-spring/zdog@npm:9.7.2"
+ dependencies:
+ "@react-spring/animated": ~9.7.2
+ "@react-spring/core": ~9.7.2
+ "@react-spring/shared": ~9.7.2
+ "@react-spring/types": ~9.7.2
+ peerDependencies:
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
+ react-zdog: ">=1.0"
+ zdog: ">=1.0"
+ checksum: 550edcb6a3632c97a3511d35b91bc8d9ef09542846572be40017ceeea404f4a6579e34b2888ae39abf8c00f97cee2152a8266d2fe5f60176c51ab680bdad93e1
+ languageName: node
+ linkType: hard
+
"@react-stately/collections@npm:^3.4.3":
version: 3.4.3
resolution: "@react-stately/collections@npm:3.4.3"
@@ -16562,7 +16692,7 @@ __metadata:
languageName: node
linkType: hard
-"prop-types@npm:^15.5.10, prop-types@npm:^15.5.8, prop-types@npm:^15.6.2, prop-types@npm:^15.7.2, prop-types@npm:^15.8.1":
+"prop-types@npm:^15.5.10, prop-types@npm:^15.6.2, prop-types@npm:^15.7.2, prop-types@npm:^15.8.1":
version: 15.8.1
resolution: "prop-types@npm:15.8.1"
dependencies:
@@ -17135,16 +17265,20 @@ __metadata:
languageName: node
linkType: hard
-"react-spring@npm:^8.0.27":
- version: 8.0.27
- resolution: "react-spring@npm:8.0.27"
+"react-spring@npm:^9.7.1":
+ version: 9.7.1
+ resolution: "react-spring@npm:9.7.1"
dependencies:
- "@babel/runtime": ^7.3.1
- prop-types: ^15.5.8
+ "@react-spring/core": ~9.7.1
+ "@react-spring/konva": ~9.7.1
+ "@react-spring/native": ~9.7.1
+ "@react-spring/three": ~9.7.1
+ "@react-spring/web": ~9.7.1
+ "@react-spring/zdog": ~9.7.1
peerDependencies:
- react: ">= 16.8.0"
- react-dom: ">= 16.8.0"
- checksum: 4f306e30c3a425fd2b11c265ca0a7c261de0f63c0250fa6fa19eddd58c50fc9eaa463927571ee1dec39659a1bf619aaacf3352602b7724695da240ec0bc106cf
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
+ checksum: 75f31601d9a8e94e93e66ccfed2ced8cc71399835cf4d509eae6b373315f182f3b5ca0d96da7cd132f01faa6b1cf89dcf087ca43bf40e51c3202c6713f730c28
languageName: node
linkType: hard
@@ -21163,13 +21297,6 @@ __metadata:
languageName: node
linkType: hard
-"wobble@npm:^1.5.0":
- version: 1.5.1
- resolution: "wobble@npm:1.5.1"
- checksum: 315b0e659e1ffd2bae31046df8e7be53cdc81f3ebd3a4fa2ae8f15810d25524f2bee6c6cb8929a9644d5bf6034e0b4e3379e179132d84de1d4b5c5e604172b6b
- languageName: node
- linkType: hard
-
"word-wrap@npm:^1.2.3, word-wrap@npm:~1.2.3":
version: 1.2.3
resolution: "word-wrap@npm:1.2.3"