Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Associate a key to a Component name,
- * Keep in mind that the values below need to be the actual objects, not strings
- * Here's some "real code" to give you an idea */
- export const dynamic_row_render_options = {
- bootstrap3Columns : Bootstrap3ColumnsCreator,
- slider : HeroSlider
- }
- export function RenderSpecificRow(className, props) {
- const SpecificComponent = dynamic_row_render_options[className];
- return (
- <SpecificComponent {...props} />
- );
- }
- }
- // usage:
- class Bootstrap3ColumnsCreator extends React.Compontent {
- render() {
- return <div>{this.props.prop1 + ' ' + this.props.prop2}</div>
- }
- class MyComponent extends react.Component {
- // ...
- renderRow() {
- var myType = 'bootstrap3Columns';
- return RenderSpecificRow(myType,
- {
- prop1: 'hello',
- prop2: 'world'
- })
- }
- // ...
- }
Add Comment
Please, Sign In to add comment