I am new to React and I am trying to use state for the first time. For some reason statelist.name
does not return anything. Do I need to use a constructor ? Any Help would be great.
import React from 'react';
class HorizantScroller extends React.Component {
state = {
statelist: [
{name: "Brands",
items: ["1", "2", "3"]
},
{name: "Films",
items: ["f1", "f2", "f3"]
},
{name: "Holiday Destination",
items: ["f1", "f2", "f3"]
}
]
};
render() {
const { selected } = this.state;
// Create menu from items
const menu = Menu(list, selected);
const {statelist} = this.state;
return (
<div>
<div name={statelist.name}></div>
</div>
);
}
}
export default HorizantScroller;