Open ofirk12 opened 7 years ago
i discover the problem also
Are you including jQuery in your app, or is it being injected by 'react-bootstrap-multiselect'? I've changed the code recently due to people wanting to inject their own version of jQuery, so there might be a bug with that part.
Do you have a repo I can check out (or an online example)?
I'm also running into that error. I'm not including jQuery explicitly in my app.
@aaronkw - what's the actual error message you see in the console? I don't really understand the original bug report without links to code. What bundler are you using (browserify/webpack/rollup)?
I've got the same issue , the bundler is webpack
The issue for me is that previously (pre 2.2.0) the require('./boostrap-dropdown.js')
was inside the if block that checks that there's a working window. With the new version, it breaks server-side rendering because bootstrap-dropdown.js
gets loaded whether or not there's a window, and thus jQuery.fn
is undefined.
2.1.0:
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
//Necessary for Universal Javascript apps
//since JQuery requires a working window
var $ = require('./bootstrap-multiselect.js').init(
require('./bootstrap-dropdown.js').init(
require('jquery')
)
);
}
2.2.0
var bsMultiselect = require('./bootstrap-multiselect.js');
var bsDropdown = require('./bootstrap-dropdown.js');
// setup jQuery
var $;
if (typeof window !== 'undefined' && window && window.jQuery) {
$ = window.jQuery;
} else {
$ = require('jquery');
}
Related: #73 and #77
i get this meesage : /react-bootstrap-multiselect/lib/bootstrap-dropdown.js:2 [2] if (typeof jQuery.fn.dropdown !== "undefined") return jQuery; when i write var Multiselect = require('react-bootstrap-multiselect'); what can be the problem?