javascript - How can I solve this problem "Failed to compile "
问题描述
import React, { useEffect } from 'react'
import { Row, Col, List } from 'antd'
import Axios from 'axios'
import { useState } from 'react'
import SideVideo from './Sections/SideVideo'
import Subscribe from './Sections/Subscribe'
function VideoDetailPage(props) {
const videoId = props.match.params.videoId
const variable = { videoId: videoId }
const [VideoState, setVideoState] = useState([])
useEffect(() => {
Axios.post('/api/video/getVideoDetail', variable)
.then(response => {
if (response.data.success) {
setVideoState(response.data.videoDetail)
} else {
alert('fail')
}
})
}, [])
if (VideoState.writer) {
return (
<Row gutter={[16, 16]}>
<Col lg={18} xs={24}>
<div style={{ width: '100%', padding: '3rem 4rem' }}>
<video style={{ width: '100%' }} src={`http://localhost:5000/${VideoState.filePath}`} controls />
<List.Item
//이 부분은 비디오 좋아요 부분
actions={[<Subscribe userTo={VideoState.writer._id} />]}
//따로 component 만들어서 페이지 보여주게 함.
//따로 만든 component에 사용자 id를 props로 넘겨주기 위해 userTo={Video.writer._id} 이렇게 사용
>
<List.Item.Meta
// avatar ={VideoState.writer.image}
title={VideoState.title}
description={VideoState.description}
/>
</List.Item>
{/* Comment */}
</div>
</Col>
<Col lg={6} xs={24}>
<SideVideo />
</Col>
</Row>
)
} else {
<div>...loading</div>
}
}
export default VideoDetailPage
This is my code that has a problem when I use if(VideoState.writer)
:
Failed to compile
./src/components/views/VideoDetailPage/VideoDetailPage.js
Line 63:9: Expected an assignment or function call and instead saw an expression no-unused-expressions
Search for the keywords to learn more about each error.
I don't how I can solve this problem.
解决方案
你有一个<div>...loading</div>
实际上没有用于任何事情的表达式。没有返回,没有分配给任何东西,什么都没有。您可能打算退回它,即return <div>...loading</div>;
推荐阅读
- swagger - 如何使用 swagger-codegen 或 openapi-generator 创建烧瓶服务器存根?
- javascript - 工具提示未在 SVG 中显示(使用 ECMAScript)
- html - 即使父组件的高度为零,子组件仍会显示
- aws-api-gateway - 通过 AWS 中的 ALB/ELB 和 APIGateway 实现基于 Websocket 的请求和响应有哪些可能的注意事项?
- arrays - 减少在 C 中按倍数计算所需的计算量
- android - Kotlin - 检查 URL 是否可访问时出现“I/System.out: (HTTPLog)-Static: isSBSettingEnabled false”错误
- django - Django Rest Framework - & on 方法过滤器无法按预期工作
- c++ - 你能告诉我我的代码(C++)有什么问题吗?
- python - 通过 Django 中的粘合表获取数据
- google-data-studio - 数据洞察社区连接器:如何更改数据新鲜度间隔