Created
June 28, 2017 05:11
-
-
Save j5bot/70f3652403761baefa32120d59b64ca9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; // needed for JSX | |
export const AnyTag = (props) => { | |
// Create a Capitalized reference to a String | |
// whatever is in the string will be the tagname of our "Component" | |
const TagName = props.tagName; | |
// make a copy of props that we can mutate | |
let propsCopy = { ...props }; | |
// get rid of the tagName property, since we're using that for the | |
// tag name, not for one of the tags' attributes / component's properties | |
delete propsCopy.tagName; | |
// Render whatever tag is in props.tagName, with all of the attributes/props | |
// defined on AnyTag except tagName, and all of the children of AnyTag | |
return ( | |
<TagName { ...propsCopy } /> | |
); | |
}; | |
export default AnyTag; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment