0

I'm rendering User's Image and username at the Header Title if it recieve outfitDetail props.

class OutfitDetail extends Component {
  static navigationOptions = ({navigation, screenProps}) => ({
    ...
    headerTitle: (
      !!screenProps.outfitDetail ? (
            <View style={styles.container}>
              <TouchableOpacity onPress={() => this.props.navigation.navigate('Profile', {id: userId})}>
                {this._renderAvatar(screenProps.outfitDetail.user.image)}
              </TouchableOpacity>
              <View style={styles.content}>
                <View style={styles.contentHeader}>
                  <RkText rkType='header5'>{screenProps.outfitDetail.user.username}</RkText>
                  <RkText rkType='secondary4 hintColor'>
                    <TimeAgo time={screenProps.outfitDetail.publish}/>
                  </RkText>
                </View>
                <RkText rkType='primary3 mediumLine'>{screenProps.outfitDetail.content}</RkText>
              </View>
            </View>
      ): (<Text>Loading</Text>)
    ),
    ...
  });

so if screenProps.outfitDetail is not null (not fetched yet), it renders Loading, otherwise it renders user's photo and username.

Why am I getting Unexpected token, expected , error (React-navigation)? the error occurred on the third line of code above.

merry-go-round
  • 4,533
  • 10
  • 54
  • 102

1 Answers1

1
static navigationOptions = ({navigation, screenProps}) => ({
headerTitle: (
    !!screenProps.outfitDetail ? (
        <View style={styles.container}>
          <TouchableOpacity onPress={() => this.props.navigation.navigate('Profile', {id: userId})}>
            {this._renderAvatar(screenProps.outfitDetail.user.image)}
          </TouchableOpacity>
          <View style={styles.content}>
            <View style={styles.contentHeader}>
              <RkText rkType='header5'>{screenProps.outfitDetail.user.username}</RkText>
              <RkText rkType='secondary4 hintColor'>
                <TimeAgo time={screenProps.outfitDetail.publish}/>
              </RkText>
            </View>
            <RkText rkType='primary3 mediumLine'>{screenProps.outfitDetail.content}</RkText>
          </View>
        </View>
  ):(<Text>Loading</Text>)
),
... other functions ...
})
Tarek
  • 687
  • 5
  • 11