Closed aleclarson closed 4 years ago
noticed a useTransition regression, my modal close animation stopped working after upgrading (it's now opening with animation and closing instantly on v9)
@brunolemos Your code looks fine at first glance.
Can you reproduce in react-spring-examples, maybe?
Everything’s fine, I think there’s a minor regression on useSprings that no longer accepts set({...})
and requires set(i => ({...}))
but I believe this was undocumented anyway!
@dbismut That should still be supported. The implementation is here:
Hmm... in my case I noticed a regression when upgrading to @next
, I'll have another look.
A beta feedback playground is a super nice idea @aleclarson let's make this a perfect release for everyone 😍👍You think i should tweet this out for exposure?
@aleclarson Here is a csb that shows the problem: https://codesandbox.io/s/003pl8m2vn
You can uncomment line 12 and comment line 13 to see the difference when dragging the colored squares or clicking the button. In the first case, only the first square moves.
I can create an issue if you'd like!
Hello there!
I've just found this issue and would like to mention that I created an issue (and repo reproducing it) that affects 9.0.0-beta.1, but also 8.0.19.
https://github.com/react-spring/react-spring/issues/646
Thank you for your time and work, react-spring is awesome I've been using it since 5.x!
The beta speeds up TypeScript considerably for me (resolving #613), but the typings seem to be buggy, causing errors where there shouldn’t be any. I’ve opened a separate issue for this: #653
9.0.0-beta.2 is now available! 🎉 Please give it a test drive. 👍
.d.ts
moduleuseSpring
92c0e484eb837f59d079ea31f634974bb3a2b291useTrail
7c557bd8d7b45c73433f47810e48217ba376b5edconfig.decay
to be a numberedit: There seem to be some TypeScript issues, so I'll be publishing another beta in a bit.
9.0.0-beta.3 is now available 👀😲
I noticed a regression with useTrail
in this release, so when the number of items is 0 then i get an error saying Cannot read props of undefined
.~
I'll try to create a repro when i get the time.
code snippet:
const data = [];
const trails = useTrail(data.length, {
config: config.stiff,
from: {
rotate: -90
},
rotate: 0,
});
The transition component crashes when the children is a boolean instead of a function but this change from 8.0.19 is not specified as breaking change on the changelog.
Created a minimal repro case, hope it helps: https://codesandbox.io/s/vv9jk778ly
@sjnonweb Bug confirmed: https://codesandbox.io/s/04058yr1pv
edit: Fixed in the next beta 🎉
@dbismut A new issue would be great! https://github.com/react-spring/react-spring/issues/642#issuecomment-485829276
@Ne3l Thank you. That will be fixed in the next beta. https://github.com/react-spring/react-spring/issues/642#issuecomment-487653288
9.0.0-beta.4 is now available 🐉
See the commits here: https://github.com/react-spring/react-spring/compare/7c775a7e2fc8e2a0061a8762665c274c392b09b7...a0c2e843fc899052fd2ec3967aa9be92fe0cf324
@aleclarson no big deal at all, just wanted to say that this line seems useless in useTrail
:
@dbismut I noticed the same thing and removed it in the first beta: 7c557bd8d7b45c73433f47810e48217ba376b5ed 👍
9.0.0-beta.5 is now available 🎉
See the commits here: https://github.com/react-spring/react-spring/compare/2fc8d534439de4561e9812db0991e54500e972c6...4e2cbbaba586e6091ac075e65b1e41681a68519a
Strange, I'm getting the Type instantiation is excessively deep and possibly infinite.ts(2589)
error from this:
const transitions = useTransition(snacks, item => item.key, {
from: { opacity: 1, height: 0, life: '100%' },
enter: item => async (next: SpringUpdateFn) =>
await next({ opacity: 1, height: refMap.get(item).offsetHeight, config }),
leave: item => async (next: SpringUpdateFn) => {
console.log('LEAVING');
await next({
life: '0%',
config: { ...config, duration: item.persisting ? 0 : SNACKBAR_DURATION },
});
await next({ height: 0, config });
await next({ opacity: 0, config });
},
});
return transitions.map(({ key, item, props: { life, ...style } }) => {
return <animated.div key={key} style={style} />;
})
Getting the error in all v9 betas
@aleclarson amazing work on these betas, it's exciting to see it evolving so fast!
I can also see the TS error @ehellman mentioned above. Here's a repro:
import React from 'react';
import { View } from 'react-native';
import { animated, useSpring } from 'react-spring/native';
const AnimatedView = animated(View);
export const MyComponent = () => {
const style = {
backgroundColor: 'red',
height: 100,
width: 100,
};
const motionProps = useSpring({
from: { opacity: 0, scale: 0 },
opacity: 1,
scale: 1,
});
const motionStyle = {
...style,
opacity: motionProps.opacity,
transform: [{ scale: motionProps.scale }],
};
return (
<View>
<AnimatedView style={motionStyle} /> // THIS LINE THROWS THE ERROR
</View>
);
};
Error:
error TS2589: Type instantiation is excessively deep and possibly infinite.
Tested with 9.0.0-beta.5
.
Thank you for your work on this! I'm very excited to have a fully typed version of react-spring
.
It seems like the interpolate helper is no longer exported?
Useful in situations like this:
import React from 'react';
import { animated, interpolate, useSprings, useTrail } from 'react-spring';
function Component(items: unknown[]) {
const trail = useTrail(items.length, {
from: {
y: 20
},
y: 0,
});
const [springs, set] = useSprings(items.length, (i) => {
return {
s: 1,
};
});
return trail.map(({ y }, i) => {
const { s } = springs[i];
return (
<animated.div
onMouseEnter={() => {
set(i2 => {
if (i2 === i) {
return {
s: 1.1,
};
}
return {
s: 1,
}
});
}}
style={{
transform: interpolate([y, s], (y, s) => {
return `scale(${s}) translateY(${y})%`
})
}}
/>
);
});
}
Great work!
I found a regression, server side rendering no longer works:
6:47:27 PM: error Building static HTML failed for path "/projekt/orion"
6:47:27 PM: See our docs page on debugging HTML builds for help https://gatsby.dev/debug-html
6:47:27 PM: 616 | if (!active) {
6:47:27 PM: 617 | active = true;
6:47:27 PM: > 618 | if (manualFrameloop) manualFrameloop();else requestAnimationFrame(update);
6:47:27 PM: | ^
6:47:27 PM: 619 | }
6:47:27 PM: 620 | };
6:47:27 PM: 621 |
6:47:27 PM:
6:47:27 PM: WebpackError: TypeError: requestAnimationFrame is not a function
Seems to have been solved previously here: https://github.com/react-spring/react-spring/commit/7213e91b7ca6fd83c4ea4582cf950c44ae14deba#diff-fff0687320c3122269fa9422e7739eb0
Also seeing the type instantiation too deep error, with useSprings on web.
error TS2589: Type instantiation is excessively deep and possibly infinite.
v9 is really nice (fully typed ftw), but I'm also running into the server side rendering issue with gatsby. This is with v9.0.0-beta.5
9.0.0-beta.6 is now available 🎉
See the commits here: https://github.com/react-spring/react-spring/compare/dd6c5fa...6ba72d2
Note: I haven't looked into the "excessively deep" issue yet (see here).
@aleclarson So, latest
now points to 9.0.0-beta.6
. That's intended, right?
9.0.0-beta.7 is now available :tada:
https://github.com/react-spring/react-spring/compare/5c560cb...86d5118
from
prop are now respected when no animations have started yet.precision
now defaults to 0.005
instead of 0.01
. This should fix any visual glitches at the end of every spring animation.useChain
ref has no animations. This can happen when useSpring
is called from a parent component, and then its ref
is passed into a child component, which passes the ref
into a useChain
call. The useSpring
call won't have any animations queued up until its child components have finished rendering, and this breaks the chain.yarn build -t web -t native --watch
when you're working in a local react-spring
git clone.cancel
prop from true
to false
should always trigger an animation(s) when it makes senseHi, I'm using react-spring
with typescript, and attempting to build with beta.6
and beta.7
gives me type errors: ...react-spring/lib/common"' has no exported member 'SpringValue'.
. Using beta.5
i dont get any type errors. In addition, importing animated
causes visual studio code to slow down quite a bit, probably due to how the typings are implemented.. I believe this may be related to #613.
Default spring precision now defaults to 0.005 instead of 0.01. This should fix any visual glitches at the end of every spring animation.
Wouldn't that affect performance? Maybe increase the precision internally only when about to hit the end of the animation?
@brunolemos The precision
is only used to know when a spring has come to a full stop. It should have no bearing on performance. If you can prove otherwise, let me know.
9.0.0-beta.8 is now available :tada:
useSpring
now returns a new object on every callonFrame
prop now receives a new object on every callcancel
prop (when used with a non-zero delay) could affect updates that were queued later on (especially other delayed updates)destroy
method to prevent all future updates foreverreset
method to the Controller
class that does what the destroy
method used to do (plus a bug fix or two)It seems like since beta.5 typescript compilation has been broken (typescript@3.4.5)
node_modules/react-spring/lib/interpolation.d.ts:32:14 - error TS2304: Cannot find name 'OneOrMore'.
32 parents: OneOrMore<SpringValue>,
~~~~~~~~~
node_modules/react-spring/lib/interpolation.d.ts:38:14 - error TS2304: Cannot find name 'OneOrMore'.
38 parents: OneOrMore<SpringValue>,
~~~~~~~~~
node_modules/react-spring/lib/interpolation.d.ts:63:54 - error TS2344: Type 'In' does not satisfy the constraint 'readonly any[]'.
63 config: InterpolatorConfig<Out> | InterpolatorFn<In, Out>
~~
node_modules/react-spring/web.d.ts:1:10 - error TS2305: Module '"./lib/common"' has no exported member 'SpringValue'.
1 import { SpringValue, Solve, AssignableKeys } from './lib/common'
Let me know if it would be better to split this off to a separate issue!
I'm seeing Type instantiation is excessively deep and possibly infinite.ts(2589)
I've tried to make the smallest demo possible to show it as an example.
{
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-spring": "^9.0.0-beta.8",
"typescript": "^3.4.5"
},
"devDependencies": {
"@types/react": "^16.8.17",
"@types/react-dom": "^16.8.4"
}
}
import { animated, useTransition } from "react-spring";
export const Test: React.FC = () => {
const transitions = useTransition(true, null, {
from: { opacity: 0 },
enter: { opacity: 1 },
leave: { opacity: 0 },
});
return (
<>
{transitions.map(
({ item, key, props }) =>
item && <animated.p style={props} key={key}>Words...</animated.p>,
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Type instantiation is excessively deep and possibly infinite.ts(2589)
)}
</>
);
};
export default Test;
However I also made a Codesandbox and that doesn't error.
There seem to be regression/change of behavior with useTransition
where values are cached by key. This is problematic for us because we use this mechanism to skip transitions by using the same key, but still need the new object to be propagated to the view.
Sample:
react-spring 8 - https://codesandbox.io/s/ly068v5x2q react-spring 9 - https://codesandbox.io/s/434popoxyw
In both cases no animation is expected (correct as the key is always the same), however in v8 item
holds newly propagated value whereas in v9 item
holds value from previous render.
Is this intended change?
using react-spring@9.0.0-beta.8
using the example here https://www.react-spring.io/docs/props/gotchas for the manual api
class Test extends React.Component {
state = { show: true };
animations = new Controller({ opacity: 0 });
toggle = () => this.setState(state => ({ show: !state.show }));
render() {
const props = this.animations.update({ opacity: this.state.show ? 1 : 0 });
return (
<>
<button onClick={this.toggle}>click</button>
<animated.div style={props}>I will fade</animated.div>
</>
);
}
}
it just doesn't actually work. any ideas?
also fyi the set state block isn't accessing prevState properly
-toggle = () => this.setState(state => ({show: !show}))
+toggle = () => this.setState(state => ({show: !state.show}))
also there are no types for Controller
Thank you for this release :). I tried the latest version and it seems like not all values are animated anymore. For Example the strokeDashoffset. If I try react-spring/renderprops it works. Is this intended?
<Spring
from={{ strokeDashoffset: 157 }}
to={{ strokeDashoffset: shouldAnimate ? 0 : 157 }} config={{ duration: 1000, easing: easeOut }}>
{ style => (
<svg viewBox="0 0 60 60">
...
</svg>
)}
</Spring>
Hi all,
I'm seeing a TypeScript error when using ref's (and use the ref's in a useChain
hook).
const titleRef = useRef();
const titleAnimation = useSpring({
from: {
y: 100,
},
to: {
y: 0,
},
ref: titleRef,
});
Type 'MutableRefObject<undefined>' is not assignable to type 'MutableRefObject<undefined> & RefObject<SpringHandle>'.
Type 'MutableRefObject<undefined>' is not assignable to type 'RefObject<SpringHandle>'.
Types of property 'current' are incompatible.
Type 'undefined' is not assignable to type 'SpringHandle | null'.ts(2322)
The error makes sense, as useRef
is actually returning MutableRefObject<undefined>
, but useSpring
is expecting something else.
Edit: Fixed using
useRef<SpringHandle>(null);
Regarding change to:
Repurposed onStart prop The onStart prop is now called whenever an animated key is about to start animating to a new value. Previously, it was called every time the props were updated (even when no animations were actually started), which proved to be unreliable.
Though onStart is not called, the onRest is still called even though no animation was started. https://codesandbox.io/s/dreamy-sea-3el3n
@aocenas Thanks for pointing that out! It's probably the incorrect behavior, but onRest
currently means "all updates have completed without cancellation" instead of "all animations have come to a halt". I'll see how I can ensure the latter instead.
Do you think cancelled animations should trigger onRest
? It gets tricky, because onRest
is often used for chaining animations together, and cancelling one animation typically implies you want to cancel any dependent animations too (eg: the remaining animations in a chain).
@BowlingX I would recommend opening an issue for https://github.com/react-spring/react-spring/issues/642#issuecomment-492613412. Thanks! 👍
@madou Tracking the example bug here: https://github.com/react-spring/react-spring.io/issues/16
@ChrisW-B An example repo for https://github.com/react-spring/react-spring/issues/642#issuecomment-491309508 would be helpful. Thanks!
I had been having some issues with VSCode performance recently and I spent some time looking into it tonight—for the particular project I'm working on it seems that the new TS typings are the cause for a good bulk of my Intellisense / tsserver slowdown. Here are some rough numbers from the VSCode process monitor. This is running the latest 3.5-rc build of TypeScript.
File at rest (with v9 typings active):
1 second after save/change (CPU spikes up to 280%):
File at rest (typings commented out):
It's hard for me to even get a picture of the jump without the typings, as it garbage collects pretty quick (spikes to ~400 MB/85%-100% CPU usage). Looking at the typings themselves, there's some pretty crazy stuff going on (hard API to type), so I'm not entirely surprised to find this. Something we probably want to keep an eye on though, as it's been a real drag on my TS dev experience lately... enough that I've disabled these typings for now.
This isn't an entirely unique problem as styled-components has recently had some issues.
@aleclarson Well if the onRest
should mean "all animations have come to a halt" than I think it should be called also on canceling (meaning someone called stop()
right?) but maybe with boolean argument to mark whether the animation is finished (or in other words that the value of the animation equals the configured to
value). Or if it is already possible to get that from current API it just needs to be in the docs. That way you could do
onRest: (canceled: boolean) => {
if (!canceled) {
// more animations
}
}
@ksaldana1 Have the same issue both in VS code and WebStorm. Was much worse in 3.4 TS, in 3.5 it is much better but still ended up using my own simplified typings.
https://github.com/react-spring/react-spring/issues/325
@aleclarson I try v9-beta with nextjs look like animation flashing again when I change route with animation. It works fine on v8 and feels smoother.
v8 example https://react-spring-325-aszmjdhnnv.now.sh
v9 example https://react-spring-325-tkuptdounw.now.sh
codesandbox (code example but this behavior does not effect on codesandbox) https://codesandbox.io/s/reactspring-325-vu8en
try to change route between about page and contacts page slowly, you will see flashing white background before they animate.
9.0.0-beta.9 is now available :tada:
https://github.com/react-spring/react-spring/compare/1e1c19d...2261d9b
.d.ts
modules for typesanimated
is now supportedFrameLoop
classframeLoop
global (for custom FrameLoop
instance)skipAnimation
global (for making all animations instant)isAnimated
function (used to test for Animated
nodes)Parallax
component in TypeScriptuseTrail
now receive a spring indexuseTrail
zdog
available as react-spring/zdog
or @react-spring/zdog
@react-spring/web
etcreact-spring
package can still be used like before, but the react-spring/renderprops
module no longer exists (use import { Spring } from 'react-spring'
instead)react-spring/universal
package is a mirror of @react-spring/core
@react-spring/animated
targets
and packages
directories for source codeThanks for your hard work! However, 9.0.0-beta.9
did not fix the issue with slow typings. Importing animated
still causes VS Code to run very slowly.
9.0.0-beta.10 is now available! 🎉
tiny-invariant
import@react-spring/envinfo
for bug reports@aleclarson
The react-spring package can still be used like before, but the react-spring/renderprops module no longer exists (use import { Spring } from 'react-spring' instead)
Look like import { Spring } from 'react-spring' does not work in 9.0.0-beta.10.
In 9.0.0-beta.10
, the main
entry point file (index.cjs.js
) is missing.
I just released react-spring@9.0.0-beta.11
with a hotfix for the incorrect main
module.
In
9.0.0-beta.10
, themain
entry point file (index.cjs.js
) is missing.
Note: That module should not be referenced directly, since it doesn't exist anymore.
Replaced by #985