I need some help, I want to populate data into a Dropdown, I'm using material-ui but I don't know how to do it, I really new to react, I know that I can use props and then pass those to the dropdown but It's not that clear for me.
This is my code:
import React from 'react';
import DropDownMenu from 'material-ui/DropDownMenu';
import MenuItem from 'material-ui/MenuItem';
export default class CreateLinksave extends React.Component {
constructor(props) {
super(props);
this.state = {value: 1
};
this.handleChange=this.handleChange.bind(this);
}
handleChange(event, index, value) {this.setState({value});}
render() {
return (
<div className="container">
<div>
<RaisedButton label="Copy an existing Global Multisave"/>
</div>
<div>
<DropDownMenu value={this.state.value} onChange={this.handleChange}>
<MenuItem value={1} primaryText="Never" />
<MenuItem value={2} primaryText="Every Night" />
<MenuItem value={3} primaryText="Weeknights" />
</DropDownMenu>
</div>
</div>
);
}
}
as you can see, I have some options in my dropdown "hardcoded" but I want to make it dynamic, so if more options are added to props then this populate them automatically.
Can someone please help me with this.
Regards.