"Warning: NaN
is an invalid value for the opacity
css style property" in @react-spring/web but it works 100% as intended
#1445
-
I found an example on the web about flipping a card, and adapted it to my project. const { transform, opacity } = useSpring({
opacity: isFlipped ? 1 : 0,
transform: `perspective(700px) rotateY(${isFlipped ? 180 : 0}deg)`,
config: { mass: 3, tension: 1000, friction: 80 }
}) Here is the offending code <StyledFrontFace style={{
opacity: opacity - 1,
transform
}} color={cardColor}>
...
</StyledFrontFace> Since If I instead write this, no error is shown in the console. <StyledFrontFace style={{
opacity,
transform
}} color={cardColor}>
...
</StyledFrontFace> Am I doing something wrong here that I should solve in a different way? |
Beta Was this translation helpful? Give feedback.
Answered by
joshuaellis
Apr 22, 2021
Replies: 1 comment 1 reply
-
if you wanted to do the following: <StyledFrontFace style={{
opacity: opacity - 1,
transform
}} color={cardColor}>
...
</StyledFrontFace> You should use the <StyledFrontFace style={{
opacity: opacity.to(o => o - 1),
transform
}} color={cardColor}>
...
</StyledFrontFace> I think that should work. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
revosw
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you wanted to do the following:
You should use the
to
method of theSpringValue
:I think that should work.