question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React-spring useTransition behaves wrongly

See original GitHub issue

I have a Preact/Nextjs app when a thumbnail is clicked a fixed element slides on top. React-spring is used for animating the slide-up. The first time the transition works smoothly. The second time there is a small delay and the top component is visible without transition. It is even misplaced from the top, that it normally is not.

The transition works without problems in React.

The Relevant code is:

import { useTransition } from 'react-spring'

const projectDetailVisibility = useMappedState(mapState)

const transitions = useTransition(projectDetailVisibility, null, {
	from: { display: 'none', transform: 'translate3d(0, 100vh, 0)' },
	enter: { display: 'initial', transform: 'translate3d(0, 0vh, 0)' },
	leave: { display: 'none', transform: 'translate3d(0, 0vh, 0)' }
})

return (
	<Main>
		{transitions.map(({ item, key, props }) => item && <IndexDetail key={key} styleProps={props} />)}
		<IndexList title={title} filterCategory={filterCategory} match={match} />
	</Main>
)

Does Anybody have experience with using useTransition from react-spring with Preact? Does this problem come from “Next-level conditional rendering”? Does Preact has different mount/unmount behaviour than React, that can cause this?

Versions: next": “^9.0.3-canary.2” “preact”: “^10.0.0-rc.0” “react-spring”: “^9.0.0-beta.9” (I have tried stable 8 versions without change in behaviour)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JoviDeCroockcommented, Jul 23, 2019

Hey, if it’s not too much trouble could you give a reproducible example. The causes I can think of from the top of my head are quite wide and I have no experience with react-spring.

0reactions
secretlifeofcommented, Jul 29, 2019

Thank you also for your answer! Can I contribute some how? Is there a possibility to set the options within my nextjs/preact app?

Read more comments on GitHub >

github_iconTop Results From Across the Web

React: Spring transition not behaving properly - Stack Overflow
The Transtition changes the opacity in your example, but you never give the changed values to you rendered component.
Read more >
Spring Configs | React Spring
It directly controls how your springs behave and can customized on a spring by spring basis (e.g. opacity and scale could be different...
Read more >
What's wrong with my react-spring animation? I'm trying to set ...
I'm trying to set it up exactly like the example. Why doesn't my code work, even though the react-spring has ...
Read more >
React Spring - Getting the Most Out of React Animation Library
useTransition - used when items are added or removed, it will animate these changes. useChain - to start and end animations in a...
Read more >
react-spring - Bountysource
Created 1 year ago in pmndrs/react-spring with 1 comments. Bug Report. The transition callback is called with the wrong Transition phase. This feels...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found