Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
React Native Router Flux dynamic route

In my React Native project I have an import:

import { Actions as NavigationActions } from 'react-native-router-flux'

I also have a prop type for a route of this.props.route which equates to 'someRoute'. I would like to use the two together effectively like this:

<TouchableOpacity onPress={NavigationActions.this.props.route}>

Obviously that doesn't work but how can use the two together?

I've tried

const { route } = this.props
<TouchableOpacity onPress={NavigationActions.route}>

and also

<TouchableOpacity onPress={{$NavigationActions}.${route}}>

but neither work. Can anyone show me what I'm doing wrong

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

See react-native-router-flux minitutorial.

You aren't meant to access their props.

<Router>
  <Scene key="root">
    <Scene key="pageOne" component={PageOne} title="PageOne" initial={true} />
    <Scene key="pageTwo" component={PageTwo} title="PageTwo" />
  </Scene>
</Router>

<Text onPress={Actions.pageTwo}>This is PageOne!</Text>

Edit:

Since you are looking forward dynamic redirection, the approach is the same as if you were dealing with objects.

a = { foo: 'bar' } -> a.foo or a['foo'] (second being the dynamic version)

That is Action[page] in your case.

Which becomes

const route = this.props.route;
<TouchableOpacity onPress={NavigationActions[route]}>

Make sure that route is actually the key that the Scene has.

over 4 years ago · Santiago Trujillo Report

0

You can try like this NavigationActions[this.props.route] if your router have a scene with the value this.props.route

<TouchableOpacity onPress={NavigationActions[this.props.route]}>

If this doesn't work check the Router you defined whether it have a scene with key have the value of this.props.route.

over 4 years ago · Santiago Trujillo Report

0

You can use this:

const route = this.props.route;
Actions[route]()
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!