Is it a bad practice to use jQuery in ReactJS? [closed] - javascript

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I personally use pure javascript in a ReactJS project (or any other project). But I've been thinking lately that is a bad practice to use jQuery in ReactJS?
I've used jQuery when I was learning ReactJS and I don't mean any other external javascript file, what I mean is :
if (form.status === 200) {
$(".element").val("");
}
and felt really bad using this kind of patch work, later I learned about this.setState({});
But, given in some circumstances, such as making ajax calls, is it a good idea to use jQuery?

It's a bad practice because React uses a concept called a Virtual DOM instead of a real DOM. And React isn't aware of the changes made outside of this Virtual DOM. When you use jQuery or any other library that manipulates the DOM, React gets confused.
If you want to use jQuery for AJAX purposes, you can just use a library specifically made for AJAX, like Axios or the native Fetch API.

Related

General questions about php and react.js [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I'm about to learn react.js but I have a lot of questions,
if I'm learning react do I need PHP?
Do I need PHP with react.js and how will I use it inside PHP if possible
if I do PHP do I need React?
React.js is a javascript front-end library. It is fully written in javascript and that is the only language you need to know to use it.
PHP is a scripting language that is generally used to create the backend of your applications.
So yes you could technically develop your backend using PHP and then use React to create the frontend of your application, however it would be easier to simply use javascript to create both the backend and the frontend of your project.
If you're interested in backend development using javascript, I recommend you start by looking at node.js and the express.js library.

Why we need React if jQuery is doing all things already [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
What are main differences between ReactJS and jQuery? All the things are already can be done by jQuery itself then why we need React?
I searched in google and still am not clear about it.
Mostly it explains about the benefits in terms of "views", "components, "state", etc -- concepts that are unfamiliar for someone like myself who has only a superficial understanding of frameworks.
And where we have to use the React? Even for a small application (basic CRUP operation with some validation) we can use or it's really needed for a large application?
jQuery is a JavaScript library that simplifies HTML DOM tree manipulation, event handling, animation, and Ajax.
React allows you to update and render specific components when your data changes, which is great for development of single-page or mobile applications.
React is great for creating reusable sections of UI code, and layering them on top of each other so that you don't need to re-render the DOM as often. I have heard many people say that the more you need to update your DOM, the more you should lean towards React because it is built to treat your application's elements independently, which can make UI/UX seem a lot smoother. jQuery provides independent functions to your code to perform tasks, so it is great for making minor changes to the DOM, without having to restructure your whole UI.

The best way to pass data from vanilla Javascript to React? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am integrating some react+redux code into a website that is made completely in vanilla JS(with some JQuery), CSS, and HTML. The plan is to integrate the entire website into React, but won’t be complete for awhile and for right now the best plan is to integrate the required react code into the current stack. This would be easy if both the react code and the vanilla JS code didn’t have to communicate with each other, but that unfortunately isn’t the case. In particular, I need to be able to pass some of the data from all the vanilla JS already written into particular React components. I am having trouble in deciding the best way to do this. I found this great article which explains how to do this with a publisher/subscriber method, linked here:
http://www.primaryobjects.com/2017/05/08/integrating-react-with-an-existing-jquery-web-application/
This way seems fine, but it is a little convoluted for my use case and will require some significant code refactoring in order to implement properly. Is there an alternative way to accomplish my goal?
NOTE: The React code uses JSX and not JS.
The best way I can think of is a global state management like redux where you can store the data. Subscribe the react components, and the vanilla JS modules to the store which will enable data to be shared across both.

What Javascript framework should I use with the following requirements? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I was wondering if anyone can help in choosing a framework as this is my requirement:
We have to use our own model, we have an internal JS Database that is our model that sits inside the browser and syncs with the remote server, so this is a deal breaker as we have to use our Model and not the framework's... We will have to manually handle any mapping between GET and SET any data from and to, the Model... (can I even use a JS Framework with this requirement)
We will use Bootstrap for the UI so we don't need any Framework that comes with UI such as Ext JS, we need pure framework
We would like (but don't have to) keep using jQuery. This is not a deal breaker, but if we can continue and use jQuery it will make our learning curve shorter.
We need good Routing capabilities including the ability to change the actual View (i.e.: show hide DIV of current selected route) and not just fire an event when new Route is selected.
Binding and Templates would be a plus (I believe all good frameworks have it)
A light Framework would be better, but not a must.

Use getters/setters from framework/language or define your own explicit ones [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Where I was working as an intern, working on a JavaScript front end project with Backbone.JS, I was using those getters and setters as provided by the framework (Backbone) but was asked to define my own to make it clear whats public/private. I was more for using those provided by the backbone. Whats the better practice or recommended method here?
Then recently, I was developing my own ExpressJS/Mongoose app, I started off thinking I define a Todo model then a Todos collection that exposes functions like byId, byList etc, but then I was thinking perhaps I should just use those provided by Mongoose?
The advantage of using the provided getters/setters will be
Less code, less bugs
standard way of getting/setting. Instead of 2 (from framework + custom)
Another developer will just need to learn the framework instead of my custom code to understand whats happening
Cons:
a little longer code
less sense of whats private whats not, but I think this is not very important ... esp in a dynamic language
Again, whats recommended here?
If the framework allows it to you, write your own getters/setters only when you have to modify the behaviour of the default getters/setters.
There's no reason to write them if not needed, IMHO.

Categories

Resources