Fehlermeldung:
TypeError: Cannot read property 'split' of null
Lösung:
Ein Fragezeichen hinter der Variable vor dem split() einfügen
(this.state.keywords)?.split(";").map(keyword => <a href={this.baseURL + "?k=" + keyword}> {keyword}</a>
|
Um eine Null Variable zu verhinden, kann man ein ? hinter eine Variable und einer Funktion anfügen, wodurch diese nur noch ausgeführt wird, wenn ein Wert vorhanden ist.
TypeError: Cannot read property 'split' of null Article.render D:/Programmierung/Web/Demo/CodeDocu/CodeDocu/ClientApp/src/components/Article.js:98 95 | </div>
View compiled This screen is visible only in development. It will not appear if the
app crashes in production.
|
React Code with .split(";").map..