Forked from j5bot/CapitalizedReferenceComponentExternals.jsx
Created
April 13, 2021 07:30
-
-
Save iivanovw7/09b241f777b26c212e362d4bbf7e4ed3 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'; // required to use JSX | |
export const CapitalizedReferenceComponentExternals = (props) => { | |
// get references to all possible components | |
// that this component might render | |
const { type, components: Components } = props; | |
// make a Capitalized reference to a specific component | |
// which we'll render | |
let Component = Components[ type ]; | |
// render the component | |
return( | |
<div> | |
<p>I'm wrapped!</p> | |
<Component { ...props } /> | |
</div> | |
); | |
}; | |
export default CapitalizedReferenceComponentExternals; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment