Basically I am start learning Rxjs and I am a little bit confused between React and Rxjs. I was supposing that Reactjs and Rxjs is same.
Questions:
If Reactjs and Rxjs is the same then why are we using Reactjs over Rxjs or vise versa?
If Reactjs and Rxjs not same, then please briefly differentiate both the languages.
This is really different, React is view library and Rxjs is reactive programming library for javascript. You can use Rxjs inside react view but in reactjs, people usually use a library like Redux, flux, mobx or relayjs (if they use graphql) for data flow.
ReactJs is a view library UI.
ReactiveX or rxjs is a concept, methods or patterns for asychronous programming
RxJS is a library that allows us to easily create and manipulate streams of events and data. This makes developing complex but readable asynchronous code much easier.
Creating large asynchronous applications is not the easiest thing to do. We have all witnessed the issues callback hell can cause. Due to this growing concern, people have taken it upon themselves to improve the asynchronous JavaScript landscape. We have all heard of promises, generators, and async/await. There is another solution, and it is called RxJS.
Reference Link
ReactJS
In the simple and popular term, React is the V (View) in MVC (Model/View/Controller).
React is a JavaScript library (from Facebook) that is used to render views (for example, HTML pages) dynamically based on some state, which is often in the form of data. React then updates the generated views whenever the original state changes. React is a small but powerful library, with the power being more in the concepts than in the implementation.
Reference Link
React is a javascript library for building user interfaces and makes it painless to create interactive UIs.
RxJS is a javascript library for reactive programming using Observables and makes it painless to compose asynchronous or callback-based code.
Both these javascript libraries are not comparable to each other since they serve different purposes, but together they can create better single-page applications.
Related
I have some Question in mind while switching to context API in react js .
What is the advantages of New context API in React js .
Can we use Redux along with context api ?
What are the overcome of context api on redux if any ?
so here is the answers to your questions.
With context react now have builtin support for state management so you don't need third party lib like redux or mobx.
Yes, you can but not required, however, you can use reducers with context to handle complex state management.
Less boilerplate code, especially with hooks and not dependency on third party lib and for small project context, makes it very simple and easy.
If you are looking for example then I created this repo to demo and check other branches to explore more ways of using context.
https://github.com/smkamranqadri/react-hooks-context-todo
I'm learning react recently. I don't understand why any online tutorial said that react has View Layer only. But I think react has Controller Layer only.
Can any one help me understanding how react has View Layer?
If we think about a web app that utilizes React as utilizing a Model View Controller architecture then your tutorial makes sense. React acts as your view, but interfaces with your server. Your server acts as your controller, but interfaces with your database. Your database acts as your model.
A React application can be written completely in JavaScript files. In this case you would utilize JSX for your template structure and JSS for your styles.
React also gives you the ability to manipulate your DOM using JavaScript. It simplifies this by giving you lifecycle methods to work with, or hooks. Behind the scenes React uses a virtual DOM and a process called reconciliation to make updates to only the components that require changes based on the JavaScript logic you implement. This makes React applications very efficient, and gives you a tremendous amount of control over your UI.
This is a very broad answer, but I think you need to spend some more time looking through the docs and watching more tutorials to understand the framework and how it fits into a web app's stack. Hopefully this helps point you in the right direction. It's a fantastic framework, so stick with it!
I would like to know if it is possible to create a React project containing Redux library and then export it in another project? Until now, I only create components that display data. So I never wonder if it is possible.
The goal is to develop a little chatbot that communicates with an API. Then, this project will be used in several React projects.
Is it possible to do this? If yes, is it a good practice?
I have searched on the web and on Stack Overflowbut I didn't find any answer.
Sorry if the question has already been asked.
Thanks.
It is possible. A React component is a JavaScript function or a class. It can contain any JavaScript code. So a companent that is exported to other projects can manage its state using Redux.
Redux makes sense when the state handling is complex. Your component seems simple since all it does send data to an API and show received data. If you think it is complicated and that it would be difficult to implement it using pure React alone, you can use Redux.
Reference MV* Architecture using React js
I understand that React is an View Engine and it still requires many other libraries like Redux..etc.
Is there a list of libraries to be used along with React to build a complete ecosystem like Angular ?
The React/JS ecosystem has become so rich, you can't really decide of a set of libraries to use by default in every projects.
It really depends on your needs.
Many people choose to generally go with react-router for the client-side routing, react-dom to interact with the DOM, redux for the state management, and react-redux to connect your components to the redux state.
You might find better answers by looking at the code of these react boilerplates, some of them explain there choices: http://andrewhfarmer.com/starter-project/
One of the key decisions in choosing React over Angular for us was that React is a technology, not a framework.
The ability to mix librairies to your needs is the big plus; there is no best list. As a quick example, redux makes tons of sense for us for the webapps, however it does not for the react-native mobile app where it may not blend well with the Navigator or may be overkill...
On my Angular JS preparation; I came to know about ReactJS which is built on top of Flux and then heard about Redux. Now wondering how AngularJS related to ?
React is not built on top of flux. Flux is a pattern (and later, the facebook/flux repo was created as an implementation of that pattern) for handling global application state, and is not specific to React, but works well with React's "state trickles from the top" philosophy. It was also developed at Facebook to be used with React.
Redux is a (different) JavaScript library for managing global application state changes, and shares some similarities with the flux design pattern, but is ultimately a different thing entirely.
None of these things have any direct relation to AngularJS.