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

View other answers to this thread
Jon's photo

Let's say the Store in a React app is S0, it changed to S1 after an action. And the DOM state is changed from V0 to V1. So theoretically it's a state changing in a state machine. Since React is in a declarative way, it fits into a state machine naturally. But jQuery does not. You have to code it carefully to make it cooperate with that state machine.

There are also another concern that is called performance. React has its way of optimizing DOM operations by separating component render stage and DOM patching stage to eliminate forced layouts. But in jQuery it can be hard because it manipulates the DOM directly. It can be tedious in large apps.

In conclusion, my answer is: you can use jQuery but you need to be careful with the DOM states and performance issues, and it's sometimes much easier not to use jQuery.

Deactivated User's photo

Jon you mean one have to be aware of React lifecycle and virtual DOM as stated in point 1 here