React-native-router-flux: Deprecation in 'createStackNavigator': 'transitionConfig' is removed in favor of the new animation APIs

Created on 30 Mar 2021  路  5Comments  路  Source: aksonov/react-native-router-flux

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

Most helpful comment

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.

All 5 comments

any idea how to fix this ?

Same here, any solution?

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

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),
     });
   };


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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

llgoer picture llgoer  路  3Comments

VictorK1902 picture VictorK1902  路  3Comments

moaxaca picture moaxaca  路  3Comments

vinayr picture vinayr  路  3Comments

wootwoot1234 picture wootwoot1234  路  3Comments