Skip to content

Latest commit

 

History

History
23 lines (21 loc) · 670 Bytes

06.display-order-variations.md

File metadata and controls

23 lines (21 loc) · 670 Bytes

Display UI elements in different order

Use a prop to specify order – Map through ReactElements and render it based on order prop.

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>
    )
  }
}

Related links: