[英]Component wont render
I am passing an array of objects to TileFeed
and am taking out thumbnail URLS to be used for each tile on the page. 我将一组对象传递给
TileFeed
并取出缩略图URLS用于页面上的每个图块。 The URLS are being extracted, but the actual tile isn't rendering for some reason. 正在提取URLS,但是由于某种原因,实际的图块未呈现。 When I console out the
thumb.thumbnail
I get the correct output. 当我调出
thumb.thumbnail
我得到正确的输出。
class TileFeed extends Component {
render() {
const { thumbnail } = this.props;
return thumbnail.map(thumb => {
console.log(thumb.thumbnail);
<div key={thumb._id} className="row__inner">
<div className="tile">
<div className="tile__media">
<img
className="tile__img"
id="thumbnail"
src={thumb.thumbnail}
alt=""
/>
</div>
</div>
</div>;
});
}
}
Class that calls TileFeed 调用TileFeed的类
render() {
const { videos, loading, key } = this.props.videos;
let videoContent;
if (videos === null || loading) {
videoContent = <Spinner />;
} else {
videoContent = <TileFeed thumbnail={videos} />;
}
console.log({ videoContent });
return (
<div className="explore">
<div className="row">{videoContent} </div>
</div>
);
}
You are not returning the JSX from the function given to map
. 您不是从给
map
的函数中返回JSX。 Add a return statement or remove the function body {}
to make the return implicit. 添加return语句或删除函数主体
{}
以使返回隐式。
class TileFeed extends Component {
render() {
const { thumbnail } = this.props;
return thumbnail.map(thumb => {
return (
<div key={thumb._id} className="row__inner">
<div className="tile">
<div className="tile__media">
<img
className="tile__img"
id="thumbnail"
src={thumb.thumbnail}
alt=""
/>
</div>
</div>
</div>
);
});
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.