React Context Vs Redux [closed] - reactjs

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 1 year ago.
Improve this question
I am a student trying to learn web development along with the ReactJs library. But I have a huge struggle selecting between React Context and Redux state management. I have never worked on real-time huge projects. So everyone is suggesting I should go with React context. Even my friend who is working on a real-time project in the IT field is using React Context instead of Redux in their project. So he suggests I should just stick with React Context. But I think Redux was there even before React context and is really suitable for huge projects. So a lot of the older projects may be using Redux. But Redux is really hard compared to React Context.
Can anyone give me a suggestion on whether I should just stick with React Context or I should learn Redux?

Depends on the scope of your project. There can be some problems with React Context with high frequency updates, but if it is mostly low frequency ( theme changes, authentication ) then just use React Context because it's simply better if you plan to use the data only in ReactJS and it's additional packages

Actually it is a good idea to know both. I would start with React context which is much smaller and easier to grasp, and out of the box.
Then you can switch to redux - and do some work with it. You will learn both since both are not that difficult.

Related

Using both redux and useContext in your react app [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 7 months ago.
Improve this question
Are there reasons why one would use both redux and useContext in their APP?
If so, what are they? Can you give examples of when to use either?
It is not suggested to use both redux and context api in single app.
Both context and Redux has advantages while developing the application in their own way. Depending upon the use case you need to decide whether to go with context or redux.
Context
If the application is smaller and you need to have a centralized store
that needs to store and access the datas. You can use context api. But the code
will not be that organised when compared to redux.
The below reference will provide you an outline on creating the context,
https://reactjs.org/docs/context.html#reactcreatecontext
The below will provide you the reference on using the context,
https://reactjs.org/docs/hooks-reference.html#usecontext
Redux
If the application you are developing is bigger or enterprise level
application. You can go with redux which provides more optimized code
structure compared to context api.
If you want to integrate and use redux. Use reduxtoolkit for simple and elegant usage.
Use the below link for reference,
https://redux-toolkit.js.org/introduction/getting-started
Both are excellent tools for their own specific niche, Redux is overkill just to pass data from parent to child & Context API truly shines in this case. When you have a lot of dynamic data Redux got your back!
To answer your question Yes you can use them both in the same react app but there is no reason to do so and it is recommended to use one of them depending on your needs

Pure Components in React Native using Expo [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
I started to work with React Native using Expo and I am trying to figure out what the best practices are. Due to my previous experience, I would like to avoid performance issues before they going to be difficult to handle. I've read some articles about Pure Components which seem to help to improve the performance. My question is whether Pure Components are compatible with the expo or if it even has something to do with Expo? I couldn't find any relevant information about it online.
Pure components has nothing to do with Expo. They are part of the React fundamentals.
It is impossible to teach you through a comment here the react lifecycles and performance optimizations so my best advises to you are:
Read a little bit about the react life cycles and understand when component gets rendered.
Use functional component and hooks as they will make your life much easier and it is the "modern" way to use react.
For performance improvement read a little bit about the RN bridge and learn "useMemo", "React.memo", "useCallback". The best way for me to get deeper understaning after reading documentation was watching YouTube videos. I really recommend the "Web Dev Simplified" channel.

Should I use Firebase with react. Alternative to Firebase as backend [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 2 years ago.
Improve this question
I am taking this course building a chat app with react and firebase as backend. The problem is when I got to connecting react, redux, and firebase the whole process became so complex that got me wondering what's the point of Libraries, Frameworks, and SDK if not to make the development process easier or faster at least. Please is there other alternatives to using Firebase as backend with react. (Without so many add-ons, helper-functions, and enhancers that I need to connect)
There are quite a few alternatives: PubNub etc.. but all of them will require some setup and config to make it work with react. firebase by itself is not complicated, but make it work with react piles up the complexity a bit.
Just try it a bit more and once you are done with config and setup it way more fun. Here is a simple example to try: https://www.codementor.io/#yurio/all-you-need-is-react-firebase-4v7g9p4kf
The title doesn't explain your problem. I think its not firebase thats getting in the way, but in-fact redux/ react-redux-firebase.
If you're just learning react, you should not be trying redux. Redux has a steep learning curve, and will get in the way of you understanding the real part of react. Kent C. Dodds has said:
guess what, you probably don't need a library like Redux anymore
This might be speculation, but redux might not be as popular in the future, so you might not even have to learn it in the future. You can just use Context. People often abuse redux.

React Redux vs use-global-hook? Which is better? [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 3 years ago.
Improve this question
Working on my personal project and want to use hooks inside.
I've seen a global state implementation using hooks and my question is:
which one is better to use? Redux vs use-global-hook ?
It seems super easy to manage with the global hook, but what about performance? What are advantages, disadvantages over redux?
I've built apps using both methods and didn't notice any difference in performance; although Redux bindings are supposed to prevent unnecessary renders, I'm not sure how much of an impact this would make on the final performance of the app. Furthermore, Redux offers a time travelling debugger as well as a middleware API. The following article discusses this topic in more depth:
https://frontarm.com/james-k-nelson/when-context-replaces-redux/
If you're planning to build a sizeable project of any complexity, Redux is going to provide a feature-rich store and state management via a unidirectional flow, actions, reducers, middleware, asynchronous thunks, etc. Redux is a mature pattern (based on Flux) with a great deal of "road-testing" and a thriving community. Also with Redux you'll be able to use fully stateful React class components and leverage the component lifecycle.
Global state hooks seem like a great upcoming solution for simpler components and problems where you want to keep your components functional and pure. I don't see any signs the performance would be any different, the only way to tell would be via empirical profiling.

Integrating Angular 2 with 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 6 years ago.
Improve this question
Has anybody seen any good integration using both Angular 2 and React? This video indicates that it's possible: https://www.youtube.com/watch?v=XQM0K6YG18s
I would really like to have the below in my new project if that's possible:
Angular 2 web worker, service worker - https://www.oreilly.com/ideas/angular-2-and-the-future-of-html5-apps - e.g. to separate UI drawing and calculation to run on different CPU cores
Redux data flow - e.g. maybe using react-redux or ng2-redux to connect container component with presentational component
React inline style - e.g. Radium - http://stack.formidable.com/radium/, and this video explains why: https://www.youtube.com/watch?v=NoaxsCi13yQ
The challenges:
How do I draw a line between the code that should be written in Angular 2 and React
What should be compiled first, React JSX or Typescript? - this video shows that Typescript with React is not easy: https://www.youtube.com/watch?v=9PTa9-PPVAc
I know this question is likely not to have a definite answer, but if anybody know any active project trying to solve this (I can't find it), it would massively help my investigation.
Thanks in advance.
Update in Aug/2016
It's worth pointing out that react-typescript is doable, and there is now an reliable (created by the mobx creator) boilerplate mobx-react-typescript-boilerplate available (shame on me I haven't tried).
For anybody who has interest, mobx is a functional reactive framework that works well with React and came after Redux. See State Management is Easy on Youtube.

Resources