reactjs - How to create dynamic elements in material-ui popover? -
how create dynamic elements in material-ui popover? want example it.
class mypopover extends react.component { constructor(props) { super(props); this.state = { popoveritems: [] }; } componentdidmount() { ... fetch popover items ... ... set state ... } render() { return ( <muithemeprovider> <popover open={this.state.open} anchorel={this.state.anchorel} anchororigin={{horizontal: 'left', vertical: 'bottom'}} targetorigin={{horizontal: 'left', vertical: 'top'}} onrequestclose={this.handlerequestclose} > <menu> {this.state.popoveritems.map( (item) => { <menuitem primarytext={item.name} /> })} </menu> </popover> </muithemeprovider> ) } }
you can fetching onclick or other events example fetches items 1 time when component mounted.
Comments
Post a Comment