I\'m trying to get a dropdown working inside a form for one of my React components. Here is how I\'m setting up the dropdown portion of the code, the following is inside a f
It's because you've added HTML and CSS but not the js for it. Your code doesn't know what to do when you click on the dropdown. Here is an example how you have to do that. And the code below:
class Dropdown extends React.Component {
state = {
isOpen: false
};
toggleOpen = () => this.setState({ isOpen: !this.state.isOpen });
render() {
const menuClass = `dropdown-menu${this.state.isOpen ? " show" : ""}`;
return (
);
}
}
ReactDOM.render( , document.getElementById("root"));