Since Standard and Banners are components of React not just simple Elements , you need to do something like this,
const Components = { Standard, Banners }; class ProductPages extends React.Component { render() { const ProductPage = Components[this.props.pageType]; return <ProductPage products={ [] } /> } }
Example
or with React.createElement
const Components = { Standard, Banners }; class ProductPages extends React.Component { render() { return React.createElement(Components[this.props.pageType], { products: [] }) } }
Example
however, since you can see the main idea here, to save references to Components and then use it. You can learn more about this case at Respond to GitHub Issues
Note
const Components = { Standard, Banners };
- a new ECMAScript 6 feature called Literal Object Cost Reduction
source share