-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
useTransition re-renders / mounts twice #617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
does look to me like its mounting twice, the line should read useEffect(() => {
console.log('Mounted')
}, []) Otherwise it's not a componentDidMount, but a componentDidUpdate in old lifecycle terms. What happens here is:
|
To me it looks more like it mounts on transition start (transitions.from) and on transition end (transitions.enter)?! |
I'm not sure i can reproduce, it mounts the A component once. Without the |
Sorry, you're right. I've updated the example: |
I switched to React POSE. It works now like expected. |
@drcmda, I can confirm that @Pawelsas issue is happening with me on version 8.0.19 with useTransition. I had a list with a simple accordion functionality that unintentionally re-rendered the new component after completely running the open animation. (Example with a timer in the conditionally rendered component) Updating to React-Spring v9-beta.3 fixed this for me, not sure what the issue was exactly so I'm really looking forward to the stable release of v9. Would be helpful to know what's causing it to prevent it in the future. Otherwise loving the new hooks, performance is a lot better with fewer renders in the profiler vs the old Props API. Thanks! |
should I upgrade to v9 now ? |
I am having the same issue of re-renders, even just calling the useTransition hook in a component causes a re-render. |
Do you have any news about this issue? Should i move to a beta version? or should i use react POSE. I will be waiting for a response, it's very importar issue in my project. |
Same problem. Mount - Unmount - Mount - on show, and on hide Unmount - Mount - Unmount @Pawelsas please reopen issue as it's not fixed |
Hello, thanks |
I'm having this issue too. Any workarounds? |
Anyone still seeing this bug should try v9 beta: npm install react-spring@next If that doesn't help, try the latest v9 canary. If you're still having problems, please open a new issue. 👍 |
I use
useTransition
for a transition between screens.I've implemented this based on the Simple Transition example.
Unfortunately, the entering component renders twice which causes a flickering in my special case (scroll down using ref). I've extended the example for presentation purposes. Please see the
console.log
. https://codesandbox.io/s/y7wwzyvjkz?fontsize=14Is there a simple way to avoid this behaviour or is it a bug?
Thanks!
The text was updated successfully, but these errors were encountered: