I have strings as parameter in a function and it would return a component of the same naming, example
myFunc('Home') or myFunc('MyComponent')
which should return
<Home /> or <MyComponent />
I know that I can do this
var mappings = {
Home: <Home />,
MyComponent: <MyComponent />
};
return mappings['Home']; // returns <Home />
or
return mappings['MyComponent'] // returns <MyComponent />
But can I just go straight to return the component with the same name as the parameter without creating the object mappings above?