title: How to do conditional navigation in react native?
body: <p>Hello I'm trying to do conditional navigation in react native.In my project I'm listing a set of courses and categories as a result of an api fetch request.So after clicking on each course/category  it will navigate to different screens.So What I want is on clicking on the <code>courses</code> in first screen I will get the <code>type</code> of currently selected item that whether it is <code>course</code> or <code>category</code>. So if selected item is couse I want to navigate to <code>UnitListing</code> screen and if it is <code>category</code> I want to navigate to <code>ChapterListing</code> screen.How is it possible?</p>
  
  <p><strong>updated</strong>        </p>
  
  <pre><code>navigatetoPage = (category) =&gt;{
  
        const page = category.type == "course" ? "UnitListing" : "ChapterListing";
         this.props.navigation.navigate(page, {
                id: category.id,
                type: category.type
         })
  
   }
  render(){
    return(
      &lt;View style={st.main_outer}&gt;
              {this.state.cats.map(category =&gt;
  
                                   &lt;TouchableOpacity
    style={st.btn} onPress={() =&gt; this.navigatetoPage({category})}&gt;
    &lt;Text style={{ color: "#fff" }}&gt;View Course&lt;/Text&gt;
  &lt;/TouchableOpacity&gt;
                                   )}
    &lt;/View&gt;
    );
  }
  </code></pre>
  
  <p>How do I do conditional navigation here? Please help me to find a solution.</p>