Guest User

Untitled

a guest
Dec 17th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. /** Associate a key to a Component name,
  2. * Keep in mind that the values below need to be the actual objects, not strings
  3. * Here's some "real code" to give you an idea */
  4. export const dynamic_row_render_options = {
  5. bootstrap3Columns : Bootstrap3ColumnsCreator,
  6. slider : HeroSlider
  7.  
  8. }
  9.  
  10. export function RenderSpecificRow(className, props) {
  11. const SpecificComponent = dynamic_row_render_options[className];
  12. return (
  13. <SpecificComponent {...props} />
  14. );
  15.  
  16. }
  17. }
  18. // usage:
  19. class Bootstrap3ColumnsCreator extends React.Compontent {
  20. render() {
  21. return <div>{this.props.prop1 + ' ' + this.props.prop2}</div>
  22. }
  23.  
  24.  
  25. class MyComponent extends react.Component {
  26.  
  27. // ...
  28. renderRow() {
  29.  
  30. var myType = 'bootstrap3Columns';
  31.  
  32. return RenderSpecificRow(myType,
  33. {
  34. prop1: 'hello',
  35. prop2: 'world'
  36. })
  37. }
  38. // ...
  39.  
  40. }
Add Comment
Please, Sign In to add comment