Context: I am developing a widget-based webapp, (like the defunct iGoogle, where users can choose which widgets they want to display). Each widget is a React component.
JSX is a superset of JavaScript, so you can always use native JavaScript syntax inside of JSX. For example, if classes of your components are available in global space (window
), you can do the following:
React.render(
React.createElement(window[dataFromDb.type], {name: dataFromDb.name}),
document.getElementById('try2')
);
JSFiddle here.