Skip to content
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

CSSTransition is showing state changing on re-renders during exit. #895

Open
think-carlo opened this issue Nov 1, 2023 · 1 comment
Open

Comments

@think-carlo
Copy link

think-carlo commented Nov 1, 2023

What is the current behavior?

I have a TransitionGroup managing state for a CSSTransition. The child for the CSSTransition is a single slide, which re-renders upon dispatches to update state. When the state updates and the slide re-renders, you can see the state change happen on original node in the DOM before the exit happens, causing it to look as if the animation is lagging behind.

What is the expected behavior?

I expect that original node would maintain the original state as it exits, and then the newly cloned node would render the updated state as it enters. I've given the CSSTransition a unique value as the key prop so that React can track the mounts properly, but it's still happening.

The state for the slide is pulled from a context provider, and the slide is also a forwardRef as it's a functional component.

Could you provide a CodeSandbox demo reproducing the bug?

https://codesandbox.io/s/fervent-jones-yspc9v

@dev-mingo
Copy link

dev-mingo commented Mar 13, 2024

I was able to bypass this by using

  1. useState for visibility to keep track of the visibility state
  2. useRef to keep track of the original component data
  3. useEffect to adjust the visibility and data management

on the same issue. But, a from the maintainers would be much better, instead of using a hacky workaround such as mine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants