Austin Witherow
Austin Witherow

Reputation: 486

custom sceneConfigs for navigator.push not working

I am using a component to do all of the routing in my application. Through props, all of the functions within this component are calling navigator.push.

An example...

login(navigator) {
    navigator.push({view: 'profile'});
}
showModal(navigator) {
    navigator.push({
        view: 'modal',
        sceneConfig: Navigator.SceneConfigs.FloatFromBottom
    });
}

When I navigate to profile via the login function, it navigates me with the floatromright default. When I navigate with the showModal, it also does FloatFromRight regardless of my FloatFromBottom call.

What is going on here? Am I doing this improperly?

$ react-native -v
react-native-cli: 0.1.10
react-native: 0.19.0

The solution provided by David worked. My Navigator now looks as follows:

render() {
    return (
        <Navigator
            style={styles.application}
            initialRoute={{id: 1}}
            configureScene={route => {
                if (route.sceneConfig) {
                    return route.sceneConfig;
                }
                return Navigator.SceneConfigs.FloatFromRight;
            }}
            renderScene={(route, nav) => {
                return this.renderScene(route, nav);
            }}
            />
    );
}

Upvotes: 0

Views: 264

Answers (1)

David
David

Reputation: 2821

Someone correct me if I'm wrong, but I think you have to add something like this to your Navigator:

<Navigator
    ...
    configureScene={(route) => {
      if (route.sceneConfig) {
        return route.sceneConfig;
      }
      return Navigator.SceneConfigs.FloatFromRight;
    }}
    ...
    />

Upvotes: 1

Related Questions