React-native-router-flux: Cannot pass params to screens on navigate

Created on 21 Apr 2018  路  6Comments  路  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.28 (v3 is not supported)
  • react-native v0.52.0

Expected behaviour

For the app to navigate to the new screen with the params as props.

Actual behaviour

Error code undefined is not a function (evaluating '_this2[type](routeName, res)')

image

Steps to reproduce

The code for my router looks like this:

<Scene
    key="Filters"
    component={Filters}
    hideNavBar
/>

<Scene
    key="FiltersList"
    component={FiltersList}
    hideNavBar
/>

In my Filters screen, I want to navigate to the FiltersList and pass props but I get the error code I mentioned.

This is what my action looks like:

<ListItem
    icon
    button={true}
    onPress={() => Actions.FiltersList({type: 'controller'})}
/>
    <Body>
        <Text>Controllers</Text>
    </Body>
    <Right>
        <Icon name="ios-arrow-forward" />
    </Right>
</ListItem>

Whenever I remove the params, then the app navigates to FiltersList without a problem but if I try to add the params I need then my app crash.

Any solutions around this problem?

Most helpful comment

It is because type is a prop already used in this library (i.e. reset, refresh etc..), this is why it was not working.

A quick look at the API would have helped you.

All 6 comments

If anybody had this issue, please use the react-navigation API that is provided in this package.

I wasn't really sure about what the documentation meant when it mentions the API... I guess for people familiar with the package there wouldn't be any need to mention it but the react-navigation API is accessible from Actions object.

Something along the lines of:

import { Actions } from 'react-native-router-flux';

Actions.push('FiltersList', {type: 'controller'});

It is because type is a prop already used in this library (i.e. reset, refresh etc..), this is why it was not working.

A quick look at the API would have helped you.

I try to change title using Actions.push, but prams didn't apply.

 Actions.push('settings', {
    title: Strings.interface.settings.title,
});

Same @kholiavko-roman did you end up finding a solution?

@d7laungani, I did like this:
Actions.settings({ title: 'settings title' });
And when defined all routes of the app, you need set some default value for this params:
<Scene title='my page' />

It is because type is a prop already used in this library (i.e. reset, refresh etc..), this is why it was not working.

A quick look at the API would have helped you.

I confirm this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GCour picture GCour  路  3Comments

xnog picture xnog  路  3Comments

jgibbons picture jgibbons  路  3Comments

YouYII picture YouYII  路  3Comments

maphongba008 picture maphongba008  路  3Comments