Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is alternative prev function in ReactJs?

Prev function is Jquery function. Is there an alternative to this in ReactJs? I did a lot of research. But I could not reach the result. I have tried before: previousElementSibling,previousSibling,nextElementSibling,nextSibling. They didn't solve my problem. Is there anybody who can help me about it?

 $("#diagram path[marker-end*='url']").prev('text'); 

Does this code have a counterpart in ReactJs?

like image 578
yunusunver Avatar asked Sep 04 '26 10:09

yunusunver


1 Answers

You shouldn't need jQuery if you work with React the way it's intended to:

A big difference between these two is that React works through the “virtual DOM”, whereas jQuery interacts with the DOM directly. The virtual DOM is a DOM implementation in memory that compares to the existing DOM elements and makes the necessary changes/updates. And that leads to much faster performance.

Source

Go through the docs and give it a try. You won't regret it.

like image 173
cbdeveloper Avatar answered Sep 06 '26 22:09

cbdeveloper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!