2017-03-31 5 views
0

通知がある場合、私はバッジを表示したいと思うsimple footerTabを持っています。このコードではコンポーネントにプロパティを渡す

<Button active={ this.props.ui.selectedTab === 'notifications' ? true : false } 
     onPress={() => this.selectedTab('notifications') } 
     { ...this.props.ui.notifications ? badge : null }  
> 
     { this.props.ui.notifications ? 
      <Badge><Text style={{ color:'white' }}>{this.props.ui.notifications}</Text></Badge> : null 
     } 
     <Icon name='md-notifications' /> 
</Button> 

私はボタンのためにそのバッジのプロパティを渡すことができますどのように「バッジが定義されていない」

を取得していますか?

+0

「バッジ」はどこに定義されていますか? – Li357

+0

Hmm。良い質問。私はコンポーネントのプロパティだと思っていたので、どこにも定義していません。そのプロパティを文字列としてコンポーネントに渡す必要がありますか? – CodAri

+0

バッジコンポーネント用のライブラリを使用していますか?または、自分でバッジコンポーネントを作成しましたか? –

答えて

0

しばらくして、私はそのプロパティバッジがデフォルトでtrueであることを知っていました。だから作業バージョンはこれのようでした。

<Button active={ this.props.ui.selectedTab === 'notifications' ? true : false } 
     onPress={() => this.selectedTab('notifications') } 
     badge={ this.props.ui.notifications ? true : false }  
    > 
     { this.props.ui.notifications ? 
      <Badge><Text style={{ color:'white' }}> 
     {this.props.ui.notifications}</Text></Badge> : null 
     } 
     <Icon name='md-notifications' /> 
    </Button> 
関連する問題