How do you pass in props to another component in TabBarIOS?

42 views Asked by At
      <TabBarIOS.Item
        icon={{uri: base64Icon, scale: 3}}
        title="Match Facts"
        badge={this.state.notifCount > 0 ? this.state.notifCount : undefined}
        badgeColor="black"
        selected={this.state.selectedTab === 'matchFacts'}
        onPress={() => {
          this.setState({
            selectedTab: 'matchFacts',
          });
        }}>
        <MatchFacts propsToCall={this.props.matchFacts}/>
      </TabBarIOS.Item>

==================

MatchFacts component

constructor(props) {
super(props)

this.state = {
  selectedTab: 'matchFacts',
  matchInfo: {}
}

  }

  componentWillMount(){
        this.setState({
          matchInfo : this.props.matchFacts
        })

   console.log(this.state.matchInfo)
  }

  componentDidMount(){
console.log('did mount ' + this.state.matchInfo.localteam_name)
  }

Inside my TabBar.Item tab, I want to pass in this.props.matchFacts so it can be used in the MatchFacts component. When I pass it in on the line that contains " MatchFacts propsToCall={this.props.matchFacts} " that I thought should theoretically pass in the props to the next component. When I try to access the props in the MatchFacts component it does not work. I believe i'm doing something wrong here in the lines of code I provided..

0

There are 0 answers