Why we need React if jQuery is doing all things already [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
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.

Related

Best practices regarding React and its versions with various ways to accomplish the same goal [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 2 years ago.
Improve this question
As far as I am concerned, functional components and hooks are the way to go in React, since they are more modern. However, I am surprised to see that many React references (including the official Docs themselves) still use class-based components and do not promote these new features that are supposedly better. Plus, I noticed people looking into learning React are in two minds about which of these two ways to go. So, why are the docs and other accepted examples still using older tools in React? Can one accomplish things with the old version that are still impossible with the new one?
You can accomplish everything with both class and functional components. There is no right or wrong.
If you understand functional programming paradigm and its benefits then go with functional components.
Otherwise you can technically achieve anything with class components as well.

Is it a bad practice to use jQuery in ReactJS? [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
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.

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.

How can Cycle code be broken up for creating large applications? [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 7 years ago.
Improve this question
I have gone through the official and other documents about Cycle.js
The only point I see is that it separates the main logic and their effects on DOM.
The examples given are very short like building a BMI calculator. I don't understand how developing a big app will be like on Cycle.js, and I don't understand how can I put all the code of a big app in the main() and channelize its DOM effects separately.
How can Cycle code be written to produce large applications?
I don't understand how can I put all the code of a big app in the main () and channelize its DOM effects separately.
As with any library or framework, you need to build a large app in smaller pieces, typically known as components. With cycle, components are actually just small cycle applications. You can make hundreds of components, which would all have a main function, and compose those inside of other components and so on. It's very simple, just like composing any function from other functions:
function theWholeApp() {
subComponent()
subComponent2()
}
function subComponent() {
anotherNestedComponent()
}
// etc
As you can see in the Component walkthrough, the BMI Calculator is a component built from a main function, and it utilizes a Labeled Slider component that has its own main function. Using the same technique, the BMI Calculator can be output inside another component, and so on. Components generally need to be isolated to behave as components.
Because all of the code you will write with Cycle is functional, you can divide up your code into as many or a few functions as you prefer. However, the recommended paradigm is model-view-intent, where each component is divided up into a function for each:
function main({DOM}) {
return {DOM: view(model(intent(DOM)))};
}
For a large app, you will also need routing. cycle-router by TylorS seems to be the way to go right now. Cycle is new and hasn't benefited from as much community input as projects like Angular and React. It is difficult to get started with at the moment due to lack of tutorials, examples, and documentation of various things like cycle-router. All of this will improve in time and make Cycle more viable. From a technical standpoint, Cycle is a fantastic approach for writing applications, though it may not be practical for everyone until more resources are available.
This sample project by Cmdv may help you get started.

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.

Categories

Resources