react-navigation-shared-element icon indicating copy to clipboard operation
react-navigation-shared-element copied to clipboard

Shared Element Crashing on Android. React Navigationn V5.

Open vic2tee4u opened this issue 3 years ago • 9 comments

Once I try to Navigate to my detail screen I get the following error. Error React.Children only expected to receive a single React element child Transition works well on IOS.

I'm passing sharedElementsConfig on my HomeStack.screen and when I comment that out, it works on android but transition won't show.

const sharedElementsConfig = (route: any) => {
    const { item } = route.params;
    if (Platform.OS !== 'android') {
        return [
            {
                id: `item.${item._id}.backdrop`,
                // animation: 'fade-out',
                // resize: 'none',
            },
            {
                id: `item.${item._id}.meta`,
                animation: 'fade',
                resize: 'none',
            },
            {
                id: `item.${item._id}.image`,
                otherId: `item.${item._id}.image`,
                // animation: 'move',
                resize: 'auto',
            },
        ];
    }
    return null;
};

    <HomeStack.Navigator
        headerMode="none"
        mode="modal"
        screenOptions={{
            gestureEnabled: false,
        }}>
        <HomeStack.Screen name="Feed" component={Home} options={options} />
        <HomeStack.Screen name="MovieDetails" component={MovieDetails} options={options} />
        <HomeStack.Screen name="Reviews" component={Reviews} options={options} />
        <HomeStack.Screen name="Biography" component={Biography} options={options} />
        <HomeStack.Screen name="MoviecategoryList" component={MovieCategoriesList} options={options} />
        <HomeStack.Screen
            name="MovieDetailPreview"
            component={MovieDetailPreviewScreen}
            options={options}
            sharedElementsConfig={(route) => sharedElementsConfig(route)}
        />
    </HomeStack.Navigator>

Stats: react-native : 0.63.4 "react-native-shared-element": "^0.7.0", "react-navigation-shared-element": "5.0.0-alpha1",

I'm currently by-passing android to get the app to run, any solution will be appreciated.

vic2tee4u avatar Jun 13 '21 01:06 vic2tee4u

sharedElementsConfig ought to be sharedElements. So closing.

vic2tee4u avatar Jun 13 '21 13:06 vic2tee4u

After restarting my metro bundler, I ran into the same issue again. it seems that sharedElementsConfig is the right tag but it breaks on android.

vic2tee4u avatar Jun 13 '21 14:06 vic2tee4u

Hello @vic2tee4u, I was having the same issue only on Android, but what fixed the error for me was to double check that I have the correct shared elements on the screen that I am navigating to - were the crash was happening.

So, I was navigating from a login screen to a forgot password screen and I was having:

  1. a wrong id on a shared element and
  2. I was missing a shared element completely in the forgot password screen, both of these were configured in the sharedElementsConfig object on the forgot password screen which was crashing when navigating to, only on Android, on iOS I had no issues even with this misconfiguration.

After fixing these, there was no crash. Hope this will help you! Take care!

ella33 avatar Jun 15 '21 16:06 ella33

Hey @ella33 I'm taking a closer look at the configuration, thus far, I havent seen anything missing yet. But I'll do a clean sweep just to be sure.

vic2tee4u avatar Jun 15 '21 19:06 vic2tee4u

I passed by so many problems including this issue on Android. On iPhone, it works perfectly, so I decided to bypass the integration for android.

I did this solution in my sharedElementsConfig

sharedElementsConfig={route => {
    if (Platform.OS === 'android') {
      return [];
    }
    return [route.params.card.slug];
}}

guistrutzki avatar Jul 01 '21 00:07 guistrutzki

in mine I noticed that an animation was happening this problem

before it was like this:

 return (
    <SharedElement id="cartbar">
        <Animated.View style={[styles.container, style, styleCartBar]}>
      
                     .....
                 
        </Animated.View>
    </SharedElement>
    );

adjusted:

 return (
        <Animated.View style={[styles.container, style, styleCartBar]}>
            <SharedElement id="cartbar">
               .....
            </SharedElement>
        </Animated.View>
    );

lucasvieceli avatar Aug 10 '21 13:08 lucasvieceli

Same here getting endNode errors like so Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException Error while updating property 'endNode' of a view managed by: RNSharedElementTransition

com.facebook.react.uimanager.NativeViewHierarchyManager.resolveView (NativeViewHierarchyManager.java:103)
com.ijzerenhein.sharedelement.RNSharedElementTransitionManager.setViewItem (RNSharedElementTransitionManager.java:79)
com.ijzerenhein.sharedelement.RNSharedElementTransitionManager.setEndNode (RNSharedElementTransitionManager.java:92)

evanjmg avatar Aug 12 '21 15:08 evanjmg

Related to: https://github.com/IjzerenHein/react-native-shared-element/issues/33

IjzerenHein avatar Aug 20 '21 13:08 IjzerenHein

It's unclear what this exception on Android is happening. If you can create a test-case in one of the example apps I can investigate it. This user pointed out that is might be related to reanimated2: https://github.com/IjzerenHein/react-native-shared-element/issues/33#issuecomment-903748373

IjzerenHein avatar Aug 23 '21 15:08 IjzerenHein