diff --git a/src/createSharedElementStackNavigator.tsx b/src/createSharedElementStackNavigator.tsx index 383a059..d53fcf2 100644 --- a/src/createSharedElementStackNavigator.tsx +++ b/src/createSharedElementStackNavigator.tsx @@ -19,17 +19,26 @@ function createSharedElementEnabledNavigator( ...routeConfigs, }; for (const key in routeConfigs) { - const component = wrappedRouteConfigs[key]; - if (component.name === 'Navigator') { + let routeConfig = wrappedRouteConfigs[key]; + const component = ((typeof routeConfig === 'object') && routeConfig.screen) ? routeConfig.screen : routeConfig; + if (component.name !== 'Navigator') { // console.log('Navigator detected, ignoring: ', component); - wrappedRouteConfigs[key] = component; - } else { - wrappedRouteConfigs[key] = createSharedElementScene( + const wrappedComponent = createSharedElementScene( component, rendererData ); + if (component === routeConfig) { + wrappedRouteConfigs[key] = wrappedComponent; + } + else { + wrappedRouteConfigs[key] = { + ...routeConfig, + screen: wrappedComponent + }; + } } } + return createNavigator(wrappedRouteConfigs, { ...navigatorConfig, onTransitionStart: (transitionProps: any, prevTransitionProps: any) => {