Answer the question
In order to leave comments, you need to log in
How to check for the presence in the object and draw?
it is not possible to draw the necessary data. Such a variable currentCarBrand comes to me. And there is an object, depending on the value of the currentCarBrand variable, it is necessary to draw the necessary data
const entities = {
opel: [
{
label: 'astra',
icon: '',
},
],
mercedes: [
{
label: 'GLA',
icon: <gla />,
},
{
label: 'GLE',
icon: <gle />,
},
],
bmw: [
{
label: 'x1',
icon: <bmwx1 />,
},
{
label: 'x2',
icon: <bmwx2 />,
},
{
label: 'x3',
icon: <bmwx3 />,
},
{
label: 'x4',
icon: <bmwx4 />,
},
{
label: 'x5',
icon: <bmwx5 />,
},
{
label: 'x6',
icon: <bmwx6 />,
},
],
audi: [
{
label: 'q1',
icon: <audiq1 />,
},
{
label: 'q2',
icon: <audiq2 />,
},
{
label: 'q3',
icon: <audiq3 />,
},
{
label: 'q4',
icon: <audiq4 />,
},
{
label: 'q5',
icon: <audiq5 />,
},
],
}
const renderCarGroup = () => entities.hasOwnProperty(currentCarBrand).map((item) => (
<ListItem>
<Car>
{item.icon}
{item.label}
</Car>
</ListItem>
))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question