以不同的顺序展示我们的UI组件
我们使用props来定下我们显示的顺序. 我们的组件基于我们排好序的props进行渲染.
class PageSections extends Component {
render() {
const pageItems = this.props.contentOrder.map(
(content) => {
const renderFunc = this.contentOrderMap[content];
return (typeof renderFunc === 'function') ? renderFunc() : null;
}
);
return (
<div className="page-content">
{pageItems}
</div>
)
}
}
参考资料:
看完两件小事
如果你觉得这篇文章对你挺有启发,我想请你帮我两个小忙:
- 把这篇文章分享给你的朋友 / 交流群,让更多的人看到,一起进步,一起成长!
- 关注公众号 「IT平头哥联盟」,公众号后台回复「资源」 免费领取我精心整理的前端进阶资源教程