Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User
react ; if ;

React: If then in JSX

02.01.2023 (👁3087)

 

Wie kann man eine If-then Bedingung in React im Ausgabeblock einbringen?

 

<p>Keywords string: {this.state.keywords}</p>

<p>Keywords separate:                                   

{

this.state.keywords ?

 (this.state.keywords).split(";").map(keyword =>

 <a href={this.baseURL + "?k=" + encodeURI(keyword)} style={{ margin: '4px' }}>keyword</a>

)

:null

}

</p>

 

Ternari Ausdruck

Ein Bild, das Text enthält.

Automatisch generierte Beschreibung

Problem… ansonsten, wenn der Ausdruck null ist, entsteht ein javascript fehler und gar nichts wird ausgegeben