以不同的顺序展示我们的UI组件

我们使用props来定下我们显示的顺序. 我们的组件基于我们排好序的props进行渲染.

  1. class PageSections extends Component {
  2. render() {
  3. const pageItems = this.props.contentOrder.map(
  4. (content) => {
  5. const renderFunc = this.contentOrderMap[content];
  6. return (typeof renderFunc === 'function') ? renderFunc() : null;
  7. }
  8. );
  9. return (
  10. <div className="page-content">
  11. {pageItems}
  12. </div>
  13. )
  14. }
  15. }

参考资料: