Jihwan Kim
Jihwan Kim

Reputation: 41

How to pass function to other component with react-native-router-flux(RNRF)?

I am making react-native android app now. my code is like below

...
constructor(props) {
    super(props);
    this.goToSearchComponent = this.goToSearchComponent.bind(this);
}

goToSearchComponent() {
    Actions.search({handleSearch: this.handleSearch});
}
...

Action.search() function works good, so I can see search component.

But in search component, 'this.props.handleSearch' is 'undefined'.

For test, I use code like below...

Action.search( {textText: 'hmm'} )

this works good too.. (in search component, this.props.textText = 'hmm')...

How to pass function to other component with react-native-router-flux(RNRF)?

Upvotes: 1

Views: 999

Answers (1)

Wanda Ichsanul Isra
Wanda Ichsanul Isra

Reputation: 2282

Have you tried to bind the function call like this?

Actions.search({handleSearch: this.handleSearch.bind(this)});

Upvotes: 3

Related Questions