Why is it a bad idea to mix jQuery and React?

View other answers to this thread
Yanni Nightingale's photo

I think it is necessary sometimes. E.g, in componentDidMount().

Hugo Magalhães's photo

Senior Frontend Developer

"Necessary" should not be the word in this case. If I understood correct, you are trying to say that sometimes you will need to access DOM after component mounting. And why in the hell will someone include a lib that has 400kb while you can just do document.getElementById()? jQuery made a huge impact in the JavaScript ecosystem, but it also made the developers forget about the beautiful of VanillaJS.

Irfan's photo

Code blooded

Hmm. If a website is using Bootstrap, jQuery is included.. Considering this, a minified version of jQuery is 82kb (can be compressed even more if you are chucking out unnecessary code in library).

Having said this, lets say there is a third party JS library that is only available in UMD way. In case of payment or mission critical applications users should not have access to this script unless they go on that page/service. So for such cases we can load it from componentDidMount(..). There can be other uses too.