jeśli mam kodu, który wygląda tak ...Jak dodać instrukcję logiczną, jeśli podczas renderowania React components?
var Lounge = React.createClass({displayName: "Lounge",
render: function() {
return (
React.createElement("a", {href:"/lounge/detail/" + this.props.id + "/"},
React.createElement("div", {className: "lounge"},
React.createElement("h2", {className: "loungeAuthor"},
this.props.author.name
),
React.createElement("p", {className: "loungeArticle"},
this.props.article
),
React.createElement("img", {className: "loungeImage", src: this.props.image})
)
)
);
}
});
muszę zrobić logiczna Jeśli zaznaczysz tylko wykonywali „img” komponent jeśli dane obrazu istnieje. Czy ktokolwiek zna najlepszy sposób na to, używając React?
Być może [dobra lektura na temat całego warunkowego tematu renderowania] (https: //www.robin wieruch.de/conditional-rendering-react/). –