Reputation: 57
I want to nested if else statement for href in reactjs but I got an syntax error ": expected". Here is my code:
href = {!this.props.activeLanguage ? "https://m.facebook.com/asd1/" : {this.props.activeLanguage.code == "en" ? "https://m.facebook.com/asd1/" : "https://m.facebook.com/asd2/"}}
The reason I check active Language at first it comes undefined.
Upvotes: 0
Views: 204
Reputation: 14385
Remove the inner {}
, that is object syntax and it is not a valid object. If you need to add grouping use ()
instead.
href = {!this.props.activeLanguage ? "https://m.facebook.com/asd1/" : this.props.activeLanguage.code == "en" ? "https://m.facebook.com/asd1/" : "https://m.facebook.com/asd2/"}
Upvotes: 0