Skip to content

Conversation

MatiPl01
Copy link
Member

Summary

Cherry-pick of the #7932

## Summary

@m-bert noticed that animations aren't cleaned up from the Reanimated's
CSS stylesheet when components are unmounted. As a result, we ended up
having multiple instances of animations that were no longer used.

## Example recording

### Before

<video
src="https://github.com/user-attachments/assets/9e7d9987-80eb-44b0-8519-ee5a2978f2b0"></video>

### After

<video
src="https://github.com/user-attachments/assets/cb52aaca-7dab-4dfb-bd0a-98fe7e90a09a"></video>

### Test example

<details>
<summary>Code snippet</summary>

```tsx
import { useState } from 'react';
import { Button } from 'react-native';
import Animated from 'react-native-reanimated';

export default function App() {
  const [show, setShow] = useState(false);

  return (
    <>
      <Button title="Show" onPress={() => setShow(!show)} />
      {show && (
        <Animated.View
          style={{
            backgroundColor: 'green',
            flex: 1,
            animationName: {
              from: { backgroundColor: 'red' },
              to: { backgroundColor: 'blue' },
            },
            animationDuration: '1s',
            animationTimingFunction: 'ease-in-out',
            animationDelay: '0s',
            animationIterationCount: 'infinite',
            animationDirection: 'alternate',
            animationFillMode: 'forwards',
            animationPlayState: 'running',
          }}
        />
      )}
    </>
  );
}
```
</details>
@MatiPl01 MatiPl01 changed the base branch from main to 4.0-stable July 31, 2025 09:41
@MatiPl01 MatiPl01 requested a review from m-bert July 31, 2025 09:41
@MatiPl01 MatiPl01 self-assigned this Jul 31, 2025
@MatiPl01 MatiPl01 merged commit 01cd7e5 into 4.0-stable Jul 31, 2025
2 checks passed
@MatiPl01 MatiPl01 deleted the @matipl01/cherry-pick/fix-css-animations-not-cleaned-up branch July 31, 2025 09:54
@MatiPl01 MatiPl01 mentioned this pull request Jul 31, 2025
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants