react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

Entering/exiting dosen't works on android

Open razamsalem opened this issue 1 year ago β€’ 5 comments

Description

I'm trying to use animation for entering & exiting animation and In ios its work's fine but on android its dosent works,

This is the code:

import { COLORS } from '@/src/constants/theme';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import {
  ScrollView,
  StyleSheet,
  Text,
  TouchableOpacity,
  View,
} from 'react-native';
import Animated, {
  SlideInRight,
  SlideOutLeft,
} from 'react-native-reanimated';

const LIST_ITEM_COLOR = '#1798DE';

interface Item {
  id: number;
}

export default function App() {
  const initialMode = useRef<boolean>(true);

  useEffect(() => {
    initialMode.current = false;
  }, []);

  const [items, setItems] = useState<Item[]>(
    new Array(5).fill(0).map((_, index) => ({ id: index }))
  );

  const onAdd = useCallback(() => {
    setItems(currentItems => {
      const nextItemId = (currentItems[currentItems.length - 1]?.id ?? 0) + 1;
      return [...currentItems, { id: nextItemId }];
    });
  }, []);

  const onDelete = useCallback((itemId: number) => {
    setItems(currentItems => {
      return currentItems.filter(item => item.id !== itemId);
    });
  }, []);

  return (
    <View style={styles.container}>
      <TouchableOpacity style={styles.floatingButton} onPress={onAdd}>
        <Text style={{ color: 'white', fontSize: 40 }}>+</Text>
      </TouchableOpacity>
      <ScrollView
        style={{ flex: 1 }}
        contentContainerStyle={{ paddingVertical: 50 }}
      >
        {items.map((item, index) => {
          return (
            <Animated.View
              key={item.id}
              entering={SlideInRight}
              exiting={SlideOutLeft}
              onTouchEnd={() => onDelete(item.id)}
              style={styles.listItem}
            />
          );
        })}
      </ScrollView>
    </View>
  );
}

The funny part is that the animation is works I try the your first animation code and width.value = withSpring(width.value + 50) Really animate the View, so the animation works but I need the entering prop to works... any ideas?

Steps to reproduce

1.Click on "onAdd" function to add more items (expecting entering with animation) 2. Get no animation at all (only with entering and exiting)

notice on iOS works fine just android not work

Reanimated version

3.10.0 ( I try 3.6.1 too and same problem)

React Native version

0.73.6

Platforms

iOS (entering/exiting works) Android (entering/exiting dosen't works)

Architecture

Fabric (New Architecture)

Build type

eas build dev

Device model

several android devices & android emulator

Acknowledgements

Yes

razamsalem avatar May 02 '24 13:05 razamsalem

Hey! πŸ‘‹

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

github-actions[bot] avatar May 02 '24 13:05 github-actions[bot]

Hey! πŸ‘‹

It looks like you've omitted a few important sections from the issue template.

Please complete Snack or a link to a repository section.

github-actions[bot] avatar May 02 '24 14:05 github-actions[bot]

Same here

arasrezaei avatar May 03 '24 22:05 arasrezaei

Same here

I'd love for you to let me know if you find a solution.

razamsalem avatar May 05 '24 09:05 razamsalem

Hi @razamsalem. I'm a bit confused about this issue. Layout animations are not implemented yet for the new architecture, so they shouldn't be working on both platforms.

It might be that you are using the old architecture on iOS and new architecture on Android. This would explain your problems.

If you enabled new architecture, you should have:

  • newArchEnabled=true in πšŠπš—πšπš›πš˜πš’πš/πšπš›πšŠπšπš•πšŽ.πš™πš›πš˜πš™πšŽπš›πšπš’πšŽπšœ
  • ['RCT_NEW_ARCH_ENABLED'] = '1' in πš’πš˜πšœ/π™Ώπš˜πšπšπš’πš•πšŽ (pods reinstall is required)

bartlomiejbloniarz avatar May 07 '24 15:05 bartlomiejbloniarz