Reputation: 994
I am removing jquery getting value in React by using this.refs.element.value.
How can I remove jQuery in this and do it in React way?
var arr = [];
$(".mail-checkbox:checked").closest("tr").each(function() {
arr.push( this.id );
});
Upvotes: 0
Views: 1634
Reputation: 26403
When building app with React you should not touch DOM yourself. Manipulate objects in React component and add some flag if object is checked or not. Update state and React will update DOM in best possible way.
Remember, that React uses virtual dom and you are editing with this script real dom, it will make React's dom with real dom out of sync and your app will work a lot harder to get back in sync than it should.
Upvotes: 4