I have implemented few components and I need to return it in another component by using the names in JSON.
import * as React from 'react';
import ToggleButton from '@mui/material/ToggleButton';
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
import AWSLogs from '../supportProviderTables/AWSLogs.js';
import AnalyticsEvent from '../supportProviderTables/AnalyticsEvent.js';
import Assignment from '../supportProviderLists/Assignment.js';
import AllComponents from '../supportProviderTables';
export default function ColorToggleButton() {
const [alignment, setAlignment] = React.useState(null);
const handleChange = (event, newAlignment) => {
setAlignment(newAlignment);
};
const buttonSet = [
{
value:"profiles",
text: "Profiles",
components: [
{text: "Assignment"},
{text: "AnalyticsEvent"},
{text: "AWSLogs"}
]
}
];
return (
<div>
<ToggleButtonGroup
color="primary"
value={alignment}
onChange={handleChange}
>
{buttonSet.map((item,i) => {
return <ToggleButton value={item.value}>{item.text}</ToggleButton>
})}
</ToggleButtonGroup>
{alignment !== null ? alignment.map((item,i) => {
return (buttonSet.map((ele,j) => {
if(item === ele.value){
return (ele.components.map(data => {
console.log(data.text);
const ComponentName = AllComponents[data.text];
return <ComponentName />
}))
}
}))
}) : <div></div>}
</div>
);
}
The output is expected to return all the components relevant like below
But it doesnot return the components and shows an error as "AWSLogs is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter" Can anyone help me to do this?
C