<main>
<Routes>
{routes.map((route, idx) => {
return route.component ? (<Route key={idx} path={route.path} name={route.name} element={ <route.component /> } />)
: (null);
})}
</Routes>
</main>
</div>
Is there is any syntax problem or I am using some older version functions of React?
try with <div className="Layout_content"> <main> <Routes> {routes.map((route, idx) => ( route.component ? (<Route key={idx} path={route.path} name={route.name} element={ <route.component /> } />) : (null); ))} </Routes> </main> </div>
A syntax error is immediately obvious. The code will not run at all, and the console will say "syntax error"
Should it be surrounded by braces?
Обсуждают сегодня