简体   繁体   中英

Line 9: Expected an assignment or function call and instead saw an expression no-unused-expressions

I can not figure out the error i'm getting.

Line 9: Expected an assignment or function call and instead saw an expression 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>
        )
    }

}

You need a return after if(drink) to return your 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>
  )
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM