I am trying to map my state which contains several words to a react-bootstrap dropdown menu below I have included my attempt
my state looks like "some words to view" with each word separated by a space
I have tried mapping the items into a 'ul' element using a for loop but The dropdown doesn't show anything at all.
import React, { Component } from 'react';
import '../App.css';
import {Button,InputGroup,Dropdown,DropdownButton,ButtonGroup} from 'react-bootstrap';
export default class BreakPointsDropdown extends Component{
constructor(props){
super(props);
}
render(props){
return (
<Dropdown as={ButtonGroup}>
<Button variant="outline-dark"onClick={this.props.addBreakPointMode}>Add Breakpoint</Button>
<Dropdown.Toggle split variant="outline-dark" id="dropdown-split-basic" />
<Dropdown.Menu id="menulist" onClick={()=>{
var list = this.props.listOfBreakPoints.split(" ")
var ul = document.createElement("ul")
for(let i = 0; i< list.length; i++){
let li = document.createElement("li")
li.innerHTML= list[i]
ul.append(li)
}
document.getElementById("menulist").append(ul)
}}>
</Dropdown.Menu>
</Dropdown>
);
}
};
I would like the dropdown menu to contain a list of words from my state which I can select onclick