currently i have this working code..
const HomePage = (props) => {
return (
<div className="page-home">
{
Object.keys(props.data).map(key => (
<section key={key}>
<Link to={props.data[key].route}>{props.data[key].title}</Link>
<Categories collections={props.data[key].collections} />
</section>
))
}
</div>
)
}
however, i want to use a variable to make the code more readable, but it throws an error Parsing error: Unexpected reserved word 'let'
const HomePage = (props) => {
return (
<div className="page-home">
{
Object.keys(props.data).map(key => (
// this is the var defintion that causes the problem
let obj = props.data[key]
<section key={key}>
<Link to={obj.route}>{obj.title}</Link>
<Categories collections={obj.collections} />
</section>
))
}
</div>
)
}
can someone explain why this is happening, and what the correct way to do this would be?