react-native-router-flux icon indicating copy to clipboard operation
react-native-router-flux copied to clipboard

Deprecation in 'createStackNavigator': 'transitionConfig' is removed in favor of the new animation APIs

Open khdarshan opened this issue 4 years ago • 8 comments

Version

Tell us which versions you are using:

  • react-native-router-flux v4.3.1
  • react v17.0.1
  • react-native v0.64.0

Expected behaviour

Should not recieve below warning. Deprecation in 'createStackNavigator': 'transitionConfig' is removed in favor of the new animation APIs

Actual behaviour

Following WARNING shown in console. Deprecation in 'createStackNavigator': 'transitionConfig' is removed in favor of the new animation APIs

warning - 1

khdarshan avatar Mar 30 '21 07:03 khdarshan

any idea how to fix this ?

MasterBrian99 avatar May 06 '21 12:05 MasterBrian99

Same here, any solution?

lightning331 avatar May 07 '21 04:05 lightning331

Version

Tell us which versions you are using: react-native-router-flux v4.3.1 react v17.0.1 react-native v0.64.0

Expected behaviour

I get the same warning, and I want to know, is it the reason why the transition between the two pages were not the push efect, but the default one. I use Actions.push, the two pages were in one Stack

Actual behaviour

2021-05-11 15 12 39

lafeillou avatar May 11 '21 07:05 lafeillou

I have made these changes in Store.js and I no longer get an warning, and my override of cardStyle started to work again.

This is the patch-file (also include a fix regarding the HeaderBackButton):

diff --git a/node_modules/react-native-router-flux/src/NavBar.js b/node_modules/react-native-router-flux/src/NavBar.js
index bb154e0..b4827b5 100644
--- a/node_modules/react-native-router-flux/src/NavBar.js
+++ b/node_modules/react-native-router-flux/src/NavBar.js
@@ -28,7 +28,7 @@ export function BackButton(state) {
   // returning react-navigation's back button well styled for ios and android if rnrf4-supported customization
   // is not required
   if (!state.backButtonImage) {
-    return <HeaderBackButton onPress={onPress} title={state.backTitle} titleStyle={textButtonStyle} tintColor={tintColor} truncatedTitle={state.truncatedTitle} />;
+    return <HeaderBackButton onPress={onPress} label={state.backTitle} titleStyle={textButtonStyle} tintColor={tintColor} truncatedTitle={state.truncatedTitle} />;
   }
 
   const text = state.backTitle ? <Text style={textButtonStyle}>{state.backTitle}</Text> : null;
diff --git a/node_modules/react-native-router-flux/src/Store.js b/node_modules/react-native-router-flux/src/Store.js
index 82eed18..3c15e69 100644
--- a/node_modules/react-native-router-flux/src/Store.js
+++ b/node_modules/react-native-router-flux/src/Store.js
@@ -110,8 +110,8 @@ function getProperties(component = {}) {
   return res;
 }
 function createTabBarOptions({
-  tabBarStyle, activeTintColor, inactiveTintColor, activeBackgroundColor, inactiveBackgroundColor, showLabel, labelStyle, tabStyle, ...props
-}) {
+                               tabBarStyle, activeTintColor, inactiveTintColor, activeBackgroundColor, inactiveBackgroundColor, showLabel, labelStyle, tabStyle, ...props
+                             }) {
   return {
     ...props,
     style: tabBarStyle,
@@ -124,7 +124,7 @@ function createTabBarOptions({
     tabStyle,
   };
 }
-function createNavigationOptions(params) {
+function createNavigationOptions(params, transitionConfig) {
   const {
     type,
     cardStyle,
@@ -202,6 +202,7 @@ function createNavigationOptions(params) {
       headerTitle: getValue(navigationParams.renderTitle || renderTitle || params.renderTitle, state),
       headerTitleStyle: headerTitleStyle || titleStyle,
       title: getValue(navigationParams.title || title || getTitle, state),
+      transitionConfig: transitionConfig,
     };
 
     const NavBarFromParams = navigationParams.renderNavigationBar || navigationParams.navBar;
@@ -864,9 +865,7 @@ export default class NavigationStore {
       mode,
       initialRouteParams,
       initialRouteName,
-      ...commonProps,
-      transitionConfig,
-      navigationOptions: createNavigationOptions(commonProps),
+      navigationOptions: createNavigationOptions(commonProps, transitionConfig),
     });
   };
 

yberstad avatar May 26 '21 09:05 yberstad

As mentioned above, react-navigation has removed the transitionConfig prop. However the new version provides a new API to customize the animation navigation. if you, like me, just want to have the iOS animation on Android, you should use TransitionPresets.SlideFromRightIOS from react-navigation-stack like <Stack key="root" {...TransitionPresets.SlideFromRightIOS}>. Other transition configs are also available via TransisitionsPresets in the react-navigation docs.

As RNRF is built on react-navigation, you can use the whole API animation explained in react-navigation docs and pass it as prop to <Stack />. If you want to build your own animation you can use the cardStyleInterpolator prop but it receives different parameters comparing to the old transitionConfig.

hedia-m avatar May 30 '21 11:05 hedia-m

@yberstad How do I use your patch file?

JMRMEDEV avatar Aug 29 '21 13:08 JMRMEDEV

@JMRMEDEV, I have used the patch-package, I think the readme is quite good, https://github.com/ds300/patch-package#readme.

But if you have problems using the patch, please reach out again, and I'll try to help.

yberstad avatar Aug 30 '21 06:08 yberstad

Hello,

Did someone solve this problem ?

bytemtek avatar Sep 18 '21 10:09 bytemtek