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 form parent tag which is inside the div tag that I'm returning.:
//<div>
//<form>
//some code here
<div className="row top-buffer">
<div className="col">
<div className="dropdown">
<button
className="btn btn-secondary dropdown-toggle"
type="button"
id="dropdownMenuButton"
data-toggle="dropdown"
aria-haspopup="true">
Dropdown
</button>
<div className="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a className="dropdown-item" href="#nogo">Item 1</a>
<a className="dropdown-item" href="#nogo">Item 2</a>
<a className="dropdown-item" href="#nogo">Item 3</a>
</div>
</div>
</div>
</div>
//some code here
//</form>
//</div>
However, when I click the Dropdown button, it does not display the dropdown menu and the items in it.
All my other bootstrap components are working fine. What am I doing wrong?
EDIT:
I referenced bootstrap in my index.js:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import 'bootstrap/dist/css/bootstrap.min.css'
import './App.css'
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
Am I missing something?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…