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
Problem… ansonsten, wenn der Ausdruck null ist, entsteht ein javascript fehler und gar nichts wird ausgegeben