我无法弄清楚我遇到的错误。
第9行:希望进行赋值或函数调用,而是看到一个表达式no-unused-expressions。
import React from 'react'
import { connect } from 'react-redux'
import { firestoreConnect } from 'react-redux-firebase'
import { compose } from 'redux'
function DrinkDetails(props) {
const { drink } = props;
if (drink) {
<div className="container section drink-details">
<div className="card z-depth-0">
<div className="card-content">
<span className="card-title">{ drink.title }</span>
<p>{ drink.content }</p>
</div>
<div className="card-action grey lighten-4 grey-text">
<div>Posted by {drink.authorFirstName} {drink.authorLastName}</div>
<div>30th of August, 3am</div>
</div>
</div>
</div>
} else {
return (
<div className="container center">
<p> Loading Drink...</p>
</div>
)
}
}
答案 0 :(得分:2)
在return
之后需要if(drink)
才能返回您的JSX。
if (drink) {
return (
<div className="container section drink-details">
<div className="card z-depth-0">
<div className="card-content">
<span className="card-title">{ drink.title }</span>
<p>{ drink.content }</p>
</div>
</div>
<div className="card-action grey lighten-4 grey-text">
<div>Posted by {drink.authorFirstName} {drink.authorLastName}</div>
<div>30th of August, 3am</div>
</div>
</div>
)
}