Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import React from 'react'; // needed for JSX
  2.  
  3. export const AnyTag = (props) => {
  4.  
  5. // Create a Capitalized reference to a String
  6. // whatever is in the string will be the tagname of our "Component"
  7. const TagName = props.tagName;
  8.  
  9. // make a copy of props that we can mutate
  10. let propsCopy = { ...props };
  11.  
  12. // get rid of the tagName property, since we're using that for the
  13. // tag name, not for one of the tags' attributes / component's properties
  14. delete propsCopy.tagName;
  15.  
  16. // Render whatever tag is in props.tagName, with all of the attributes/props
  17. // defined on AnyTag except tagName, and all of the children of AnyTag
  18. return (
  19. <TagName { ...propsCopy } />
  20. );
  21.  
  22. };
  23.  
  24. export default AnyTag;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement