Using the following: Bootstrap 4.0.0-beta.2, popper.js 1.13.0, and React 16.0.0. I have multiple dropdown buttons in my React app and on first clicks they don't open. After the first click they work as expected and open and close on first click. Any ideas?
<div className="dropdown">
<button type="button" className="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Edit</button>
<div className="dropdown-menu dropdown-menu-right">
<Link role="button" className="dropdown-item text-sm" to={path1}>Click me</Link>
<Link role="button" className="dropdown-item text-sm" to={path2}>Click me</Link>
<Link role="button" className="dropdown-item text-sm" to={path3}>Click me</Link>
</div>
</div>
This is how I load in app.jsx
//load bootstrap and app css
import Popper from 'popper.js';
window.Popper = Popper;
import 'bootstrap';
import 'style-loader!css-loader!sass-loader!applicationStyles';
and this is how I load bootstrap, jQuery and popper.js in my webpack.config.js file
entry: [
'script-loader!jquery/dist/jquery.min.js',
'script-loader!popper.js/dist/umd/popper.min.js',
'script-loader!bootstrap/dist/js/bootstrap.min.js',
'babel-polyfill',
'./app/app.jsx',
],
externals: {
jQuery: 'jQuery'
},
plugins: [
// new BundleAnalyzerPlugin(),
new webpack.ProvidePlugin({
'$': 'jQuery',
'jQuery': 'jQuery',
Popper: ['popper.js', 'default'],
}),
I tried adding $('.dropdown-toggle').dropdown() to the onClick and that didn't work either
Solution Turns out I had loaded Bootstrap twice using both the entry in webpack.config.js file and the import 'bootstrap' statement in app.jsx so I commented out import 'bootstrap' and it works